Upload a file into Nuxeo (via API REST) ?

1
+1
-1

Hi all,

I have managed to create a folder document and a file document into NUXEO via REST API. The code that works is accessible in this post (http://community.bonitasoft.com/groups/french-corner/cmis). Here the code :

import org.nuxeo.ecm.automation.client.jaxrs.impl.HttpAutomationClient;
import org.nuxeo.ecm.automation.client.OperationRequest;
import org.nuxeo.ecm.automation.client.Session;
import org.nuxeo.ecm.automation.client.adapters.DocumentService;
import org.nuxeo.ecm.automation.client.model.Document;
import org.nuxeo.ecm.automation.client.model.PropertyMap;

String url = "http://localhost:8080/nuxeo/site/automation";
HttpAutomationClient client = new HttpAutomationClient(url);
Session session = client.getSession("Administrator", "Administrator");
Document root = null;
// Get The Root
try {
root = (Document) session.newRequest("Document.Fetch").set( "value", "/default-domain/").execute();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Create a File Document
try {<br>
OperationRequest request = session.newRequest("Document.Create");
request.setInput(root);
request.set("type", "File");
request.set("name", "Name");
request.set("properties", "dc:title=Title");
request.execute();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

I now wish to attach a real file ("document" ) from my process . And i do not know how to handle Bonita document.

How can I do this? If you have an example or a piece of code, I'm interested.

Thanks,

Jean-Marie

2 answers

1
0
-1

Hi Antoine,

thanks a lot !

Jean-Marie

1
0
-1

Hi Jean-Marie,

May this example help. This is source code for a connector that takes a bonita document as an input and send it straight to nuxeo repository.

If you want to use it, feel free to build the project and go.

Antoine

Comments

Submitted by aCordier on Mon, 02/16/2015 - 12:25

Note:

Notifications