AnsweredAssumed Answered

Upload file / folder through webscript

Question asked by lakshya on Jan 27, 2009
Latest reply on Feb 6, 2009 by kocoubb
Hello,
I am able to create folder / document through REStful APIs.
But now facing the problem to upload the file from disk to repository.

For creating document I have written the following code :
URL = "http://localhost:8081/alfresco/service/api/path/workspace/SpacesStore/Company%20Home/children";
PostMethod method = new PostMethod(URL);
String contentType = "application/atom+xml;type=entry";
File upload = new File("testDoc.xml");
method.setRequestHeader("name", upload.getName());
method.setRequestHeader("Content-type", contentType);
method.setRequestBody(new FileInputStream(upload));
client.executeMethod(method);


testDoc.xml
<?xml version='1.0' encoding='utf-8'?>
        <entry xmlns='http://www.w3.org/2005/Atom' xmlns:cmis='http://www.cmis.org/2008/05'>
         <title>My Picts</title>
         <summary>My Picts – Summary</summary>       
         <cmis:object>
          <cmis:properties>
           <cmis:propertyString cmis:name='ObjectTypeId'><cmis:value>document</cmis:value></cmis:propertyString>
          
          </cmis:properties>
         </cmis:object>
       </entry>

How can I post the request to get the file from disk. XML should take the inputStream in this case.
How can I resolve this issue. Any pointer ??

Outcomes