cancel
Showing results for 
Search instead for 
Did you mean: 

Upload file with custom metadata

khinendra
Champ on-the-rise
Champ on-the-rise
Hi,

I want to upload a file with custom metadata. How can I do it? Please help.

I have defined three customized metadata fields in example-model.xml(pan_no, date_of_birth, applicant_name) .
Now i want to upload file with these metadata values. How can I do it??

Please Reply soon..

Thanks.
8 REPLIES 8

kbonnet
Champ in-the-making
Champ in-the-making
You have to define your properties in web-client-config-custom.xml (if you use Alfresco Explorer). After having done that, you will be able to provide values for these properties after uploading.

Is this the way of uploading you meant?

Koen

khinendra
Champ on-the-rise
Champ on-the-rise
I have done that also and those properties are also visible there in alfresco.
But I want to upload a file using web services API and want tp apply values to those properties by code.

kbonnet
Champ in-the-making
Champ in-the-making
aha. Then you need an example. Maybe this post is helpful:

http://forums.alfresco.com/en/viewtopic.php?f=27&t=7346

khinendra
Champ on-the-rise
Champ on-the-rise
yeah we have done through this. and we are able to upload content.
Now we want to add custom metadata to any file we are uploading. how can we do it.

Please F1.

kbonnet
Champ in-the-making
Champ in-the-making
I'm still not the expert in the area of the webservice, but have a look at this post:

http://forums.alfresco.com/en/viewtopic.php?f=27&t=20542

n_pancholi87
Champ in-the-making
Champ in-the-making
I am using a custom java piece of code to upload files with custom meta data (that I have created in the Alfresco extensions folder).. How can I upload the file along with the metadata that I have created?
Pls help..!

khinendra
Champ on-the-rise
Champ on-the-rise
Hi Nidhi,

You need to create object of NamedValue Class which will contain all the properties list
   
   

NamedValue[] contentProps = new NamedValue[1];
    NamedValue[] titledProps = new NamedValue[length];
    contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, fileName);
   for(int =0;i<length; i++){
         String attribName = get from list
         String attribValue =  get from list
         titledProps[i] = Utils.createNamedValue(attribName,attribValue );
   }

CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");
……………………………..
…………………………….
CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);

create.setType(documentData.get("documentType"));//take from what you have given in model file
   

n_pancholi87
Champ in-the-making
Champ in-the-making
Hi Khinendra,

Thank you for your quick reply… I am now able to update the metadata model for my file :
                   
               String attribValue ="123";               
               titledProps[2] = Utils.createNamedValue("{modelName}Property", attribValue);