How to Store attachment into hard drive .
1 answer
Hello,
Assuming that a document is declared with the name "myDocument" in your process definition:
String attachment = "myDocument";
org.bonitasoft.engine.bpm.document.Document srcDocument =
processAPI.getLastDocument(processInstanceId, attachment);
if(srcDocument==null){
throw new ConnectorException("Unable to retrieve attachment referenced by " + attachment);
}
final byte[] content = processAPI.getDocumentContent(srcDocument.getContentStorageId());
final ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
String fileName = srcDocument.getContentFileName();
String mimeType = srcDocument.getContentMimeType();
org.bonitasoft.engine.bpm.document.Document srcDocument =
processAPI.getLastDocument(processInstanceId, attachment);
if(srcDocument==null){
throw new ConnectorException("Unable to retrieve attachment referenced by " + attachment);
}
final byte[] content = processAPI.getDocumentContent(srcDocument.getContentStorageId());
final ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
String fileName = srcDocument.getContentFileName();
String mimeType = srcDocument.getContentMimeType();
Then you have to read this stream to write a file on your drive.
Comments
Maybe this will help: https://github.com/a-cordier/bonita-connector-nuxeo/blob/master/bonita-c...
The code above seems to be sending a file up, not bringing it down to the PC,. Do you have an example of this, if possible while also using the File/Directory dialog to ask where to put the document...
Thanks