create document with multiple files using java api


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);
    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 ?


0 votes

0 answers