cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass author name when upload image file?

kannank
Champ in-the-making
Champ in-the-making
Hi,

I am uploading an image from local folder to alfresco server using repository and content webservices (in .NET 2003 windows application) and that one is working fine.

I wanted to pass file name, description and author name when uploading the image file - I used the NamedValue class as follows,

NamedValue[] properties = new NamedValue[] { new NamedValue(), new NamedValue(), new NamedValue() };

properties[0].name = "{http://www.alfresco.org/model/content/1.0}name";
properties[0].value  = "Test.pdf";

properties[1].name = "{http://www.alfresco.org/model/content/1.0}description";
properties[1].value = "Test Description";

properties[2].name = "{http://www.alfresco.org/model/content/1.0}author";
properties[2].value = "Test Author";    

This code working fine and transferring the file name and description when uploading image from .NET application to alfresco and author name given here is not transferred to the image property - Is there any problem in the above code in author?

Please give me some clue to transfer author name along with file name and description - We wanted some immediate help on this.

Looking forward for your message,

K.Kannan.
2 REPLIES 2

kannank
Champ in-the-making
Champ in-the-making
Hi,

I have tested the above code for the "author" again and understood that the values are stored in the mysql database - I found all the values are stored in node_properties table in the mysql database and when I test the alfresco webclient, then the author value is not shown in the image file property and all other file properties like title / description etc are correctly shown in the web client.

We need to solve this very urgently - Please give some clue why we are not able to get the author display in webclient eventhough the author values are present in table?

Looking for your message,
Thanks,

K.Kannan.

robmeyer
Champ in-the-making
Champ in-the-making
NamedValue[] properties = new NamedValue[] {
   Utils.createNamedValue(Constants.PROP_NAME, newFile.getName()),
   Utils.createNamedValue(Constants.PROP_TITLE, title),
   Utils.createNamedValue(Constants.PROP_DESCRIPTION, description),
   Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}author", "Test Author") };
CMLCreate create = new CMLCreate("1", parentReference, Constants.TYPE_CONTENT, properties);
CMLAddAspect addAspect = new CMLAddAspect("{http://www.alfresco.org/model/content/1.0}author", null, null, "id1");
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);

The key to this code is to add the CMLAddAspect to the CML. By default, Alfresco does not support the "author" metadata. You must add it manually.