03-11-2020 02:39 PM
Hello,
I am trying to use the java api to create a document with attached files.
I saw the examples in the documentation and it's working fine.
Now I want to try my own method : one call to create the document and attach the files 🙂
Set<BlobDTO> blobs = dto.getBlobs();
if (blobs != null && !blobs.isEmpty()) {
List<Map<String, Map<String, Object>>> files = new ArrayList<>();
for (BlobDTO blob : blobs) {
Map<String, Object> content = new HashMap<>();
content.put("mime-type", blob.getMimeType());
content.put("length", blob.getContentLength());
content.put("name", blob.getFilename());
content.put("data", Base64.getEncoder().encodeToString(IOUtils.toByteArray(blob.getInputStream())));
Map<String, Map<String, Object>> file = new HashMap<>();
file.put("file", content);
files.add(file);
}
document.setPropertyValue("files:files", files);
}
The document is created in Nuxeo, and the files are attached, but it's juste text files with the "data" inside, not the good files !
Can you please tell me why It's not working ?
Regards.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.