Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-31560

Fix attachment to files:files metadata by REST API

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core
    • Tags:
    • Backlog priority:
      750

      Description

      Steps to reproduce :

      Let's use some JavaClient code to demonstrate the bug

      package org.nuxeo;import java.io.File;
      import java.util.ArrayList;
      import java.util.Date;
      import java.util.List;import org.nuxeo.client.NuxeoClient;
      import org.nuxeo.client.NuxeoClient.Builder;
      import org.nuxeo.client.objects.Document;
      import org.nuxeo.client.objects.blob.FileBlob;
      import org.nuxeo.client.objects.upload.BatchBlob;
      import org.nuxeo.client.objects.upload.BatchUpload;
      import org.nuxeo.client.objects.upload.BatchUploadManager;public class TestMultiFileBatch {    public static void main(String[] args) {
              Builder builder = new NuxeoClient.Builder();
              builder.url("http://localhost:8080/nuxeo").authentication("Administrator", "Administrator").schemas(
                      "*").connectTimeout(0).timeout(0);
              NuxeoClient client = builder.connect();        // Upload 2 files for attachments
              BatchUploadManager batchUploadManager = client.batchUploadManager();
              BatchUpload batchUpload = batchUploadManager.createBatch();
              // Upload attachment 1
              File attachment1 = new File("/tmp/file1.png");
              FileBlob attachmentBlob1 = new FileBlob(attachment1);
              batchUpload = batchUpload.upload("1", attachmentBlob1);
              // Upload attachment 2
              File attachment2 = new File("/tmp/file2.png");
              FileBlob attachmentBlob2 = new FileBlob(attachment2);
              batchUpload = batchUpload.upload("2", attachmentBlob2);        Document doc = Document.createWithName("Doc created by Java Client", "File");
              List<BatchBlob> bus = new ArrayList<>();
              bus.add(batchUpload.getBatchBlob("1"));
              bus.add(batchUpload.getBatchBlob("2"));
              doc.setPropertyValue("file:content", batchUpload.getBatchBlob("1"));
              doc.setPropertyValue("files:files", bus);
              doc.setPropertyValue("dc:title", (new Date()).toLocaleString());
      //        doc.setPropertyValue("files:files", batchUpload.fetchBatchUploads());
              doc = client.repository().createDocumentByPath("/default-domain/UserWorkspaces/Administrator", doc);
          }
          
      }
       

      After running this piece of code, the document is successfully created, a file is attached as the main blob but the "files:files" property contains 2 null values

      Expected behavior: the files are successfully attached to the "files:files" proerty

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tmartins Thierry Martins
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: