cancel
Showing results for 
Search instead for 
Did you mean: 

Webservice method for document download

vbhansaly
Champ in-the-making
Champ in-the-making
Hi,
In one of our projects, we will be integrating our application with Alfresco using webservices mechanism.
Please provide sample code for document download & upload through webservices.
2 REPLIES 2

sisao
Champ in-the-making
Champ in-the-making
This forum section is pretty filled with these topics.

Upload snapshot:

Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
         ParentReference companyHomeParent = new ParentReference(storeRef, null, "/app:company_home/cm:myfolder", Constants.ASSOC_CONTAINS, null);
         // Assign name
         companyHomeParent.setChildName("{http://www.alfresco.org/model/content/1.0}" + name);

         // Construct CML statement to create content node
         // Note: Assign "1" as a local id, so we can refer to it in subsequent
         //       CML statements within the same CML block
         NamedValue[] contentProps = new NamedValue[1];
         contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name);
         CMLCreate create = new CMLCreate("1", companyHomeParent, null, null, null, Constants.TYPE_CONTENT, contentProps);
         // Construct CML statement to add titled aspect
         NamedValue[] titledProps = new NamedValue[2];
         titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name);
         titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, name);
         CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");
         // Construct CML Block
         CML cml = new CML();
         cml.setCreate(new CMLCreate[] {create});
         cml.setAddAspect(new CMLAddAspect[] {addAspect});

         // Issue CML statement via Repository Web Service and retrieve result
         // Note: Batching of multiple statements into a single web call
         UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);    
         Reference content = result[0].getDestination();
         byte[] bytes = ContentUtils.convertToByteArray(stream);
         ContentFormat contentFormat = new ContentFormat(type, "UTF-8");
         WebServiceFactory.getContentService().write(content, Constants.PROP_CONTENT, bytes, contentFormat);
         

vbhansaly
Champ in-the-making
Champ in-the-making
Hi,
Thanks for the resposne.
I found the code in the SDK as well.