Hello,
I was trying to follow the upload example listed here (http://doc.nuxeo.com/display/NXDOC/Using+Nuxeo+Automation+Client) and for the life of me I can not get the file to attach. I can get the document created, but when I browse to the created document, there's no attached files.
I've basically copied and pasted the code with a few modifications. I create the file using newFile method instead of the getFileToUpload method.
The newFile method, I believe I grabbed from unit test and was modified as follows:
static File newFile(String content) throws IOException {
File file = File.createTempFile("automation-test-", ".xml");
file.deleteOnExit();
FileUtils.writeFile(file, content);
return file;
}
Document root = (Document) session.newRequest("Document.Fetch").set(
"value", "/").execute();
session.newRequest("Document.Create").setInput(root).set("type", "File").set(
"name", "myfile").set("properties", "dc:title=My File").execute();
File file = newFile("<doc>mydoc</doc>");
FileBlob fb = new FileBlob(file);
fb.setMimeType("text/xml");
session.newRequest("Blob.Attach").setHeader(
Constants.HEADER_NX_VOIDOP, "true").setInput(fb)
.set("document", "/myfile").execute();
// Get the file document where blob was attached
Document doc = (Document) session.newRequest(
"Document.Fetch").setHeader(
Constants.HEADER_NX_SCHEMAS, "*").set("value", "/myfile").execute();
// get the file content property
PropertyMap map = doc.getProperties().getMap("file:content");
// get the data URL
String path = map.getString("data");
System.out.println(path);
client.shutdown();
The output of the path does returns: files/84980d28-07e1-41e6-845f-6e72128307e0?path=%2Fcontent
Since I am able to retrieve file properties, does that mean the file is there? If so, how do I view it and why is not attached to the document? Am I missing something? Thanks!