How i can upload multile images in nuxeo 7.4

Hi All,

I am facing Issues in uploading multiple images in nuxeo using REST API. i am following below URL for the Batch upload https://doc.nuxeo.com/display/NXDOC/How+to+Upload+a+File+in+Nuxeo+Platform+Using+REST+API+Batch+Processing+Endpoint

  1. First I am creating a Batch using below API POST : http://localhost:8080/nuxeo/api/v1/upload i am getting below Response

    {

      "batchId": "batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77"
    

    }

  2. I am adding images to batch using below API POST http://localhost:8080/nuxeo/api/v1/upload/batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77/0

    In the body I am attaching image.
    

    POST http://localhost:8080/nuxeo/api/v1/upload/batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77/1 POST http://localhost:8080/nuxeo/api/v1/upload/batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77/2 POST http://localhost:8080/nuxeo/api/v1/upload/batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77/3 I have attached 4 images to the batch.

  3. Here i am fetching batch content using below API. GET http://localhost:8080/nuxeo/api/v1/upload/batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77 I am getting response as below [ { “size”: 8670, “name”: “shirt10.jpg”, “uploadType”: “normal” }, { “size”: 9351, “name”: “shirt9.jpg”, “uploadType”: “normal” }, { “size”: 12178, “name”: “shirt8.jpg”, “uploadType”: “normal” }, { “size”: 8170, “name”: “shirt7.jpg”, “uploadType”: “normal” } ] Now how to upload this bath to http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/test-workspace please let me know what headers and body should contain. I am not able to upload these batch images to my test-work space Please help me to solve this issue

Thanks

1 votes

1 answers

2531 views

ANSWER

According to the page you gave , wouldn't it be someting like this?

POST http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/test-workspace
{ 
  "entity-type": "document",
  "name":"myNewDoc",
  "type": "File", 
  "properties" : {
    "dc:title":"My new doc",
    "file:content": {
      "upload-batch":"batchId-293bdcf0-5366-4f5c-ac0f-a18ad7f5eb77",
      "upload-fileId":"0"
    }
  }
}

Or maybe you want to also upload the other files to the "files" property?

11/19/2015

I want to upload other files also using files property. Please let me know how to do it in the single request . by batch content is

[ { “size”: 8670, “name”: “shirt10.jpg”, “uploadType”: “normal” }, { “size”: 9351, “name”: “shirt9.jpg”, “uploadType”: “normal” }, { “size”: 12178, “name”: “shirt8.jpg”, “uploadType”: “normal” }, { “size”: 8170, “name”: “shirt7.jpg”, “uploadType”: “normal” } ]

11/19/2015



OK, after some tests and with the help of this question, here is how to do it.

curl -X POST -H 'Content-Type: application/json' -u Administrator:Administrator -d '{"entity-type": "document", "name": "myNewDoc", "type": "File", "properties": {"dc:title": "My great new doc", "file:content": {"upload-batch": "batchId-9256ed17-312a-4bbe-ae00-b8b99994200b", "upload-fileId": "0"}, "files:files": [ {"file": {"upload-batch": "batchId-9256ed17-312a-4bbe-ae00-b8b99994200b", "upload-fileId": "1"}, "filename": "test2.JPG"}, {"file":{"upload-batch": "batchId-9256ed17-312a-4bbe-ae00-b8b99994200b", "upload-fileId": "2"}, "filename": "test3.JPG"} ]}}' http://localhost:8080/nuxeo/api/v1/path/default-domain/workspaces/workspace

This is the curl version, I let you translate to the other version and adapt it to your need. There is a “file” schema part and a “files” schema one.

Also, from the page of the other question, providing a name, mime-type and length in the “file” part seems useless, as they are taken from the uploaded file. But I added the “filename”, because without it, the files tab would display the files without name, so without link to actually download them, enabling you to only download them from the summary tab.

0 votes



11/20/2015