cancel
Showing results for 
Search instead for 
Did you mean: 

Bad upload using REST API and batch

Arnault_
Confirmed Champ
Confirmed Champ

Bonjour

J'utilise la batch pour effectuer un upload :

curl -H "X-Batch-Id: mybatchid" -H "X-File-Idx:xxx.pdf" -H "X-File-Name:0" -F file=@xxx.pdf -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/automation/batch/upload

ce qui fournit l'information du batch:

[{"name":"xxx.pdf","size":291936}]

ensuite j'installe un premier fichier dans mon document en tant que "file-content":

id="8283131e-d835-4648-9bac-6a662af950f5"
curl -X PUT -H "Content-Type: application/json" -u Administrator:Administrator -d "{ \"entity-type\": \"document\", \"repository\": \"default\", \"uid\":\"%id%\", \"properties\" : { \"file:content\": {\"name\":\"xxx.pdf\", \"upload-batch\":\"mybatchid\",\"upload-fileId\":\"0\"} } }" "http://localhost:8080/nuxeo/api/v1/id/%id%"

ce qui est correct (résult du GET):

{..., "file:content":{"name":"xxx.pdf","mime-type":"application/pdf","encoding":null,"digest":"006772381d75eb52a232d3e08611ae5b","length":"291936","data":"files/8283131e-d835-4648-9bac-6a662af950f5?path=%2Fcontent"}...}

Ensuite je veux installer un autre fichier joint

curl -H "X-Batch-Id: mybatchid" -H "X-File-Idx:xxx.pptx" -H "X-File-Name:xxx.pptx" -F file=@xxx.pptx -u Administrator:Administrator http://localhost:8080/nuxeo/api/v1/automation/batch/upload
curl -X GET http://localhost:8080/nuxeo/api/v1/automation/batch/files/mybatchid

ce qui fournit l'information du batch:

[{"name":"xxx.pptx","size":291048}]

avec l'installation:

curl -X PUT -H "Content-Type: application/json" -u Administrator:Administrator -d "{ \"entity-type\": \"document\", \"repository\": \"default\", \"uid\":\"%id%\", \"properties\" : { \"files:files\": [ { \"file\": {\"name\":\""xxx.pptx"\", \"mime-type\":\"application/vnd.openxmlformats-officedocument.presentationml.presentation\" , \"length\":\"291048\", \"upload-batch\":\"mybatchid\", \"upload-fileid\":\"0\" }, \"filename\":\""xxx.pptx"\", \"length\":\"291048\" } ] } }" "http://localhost:8080/nuxeo/api/v1/id/%id"

Mais qui ne fonctionne pas (aucune erreur):

{... "properties":{..."files:files":[{"file":null,"filename":"xxx.pptx"}]...}

Bien sûr si j'installe manuellement mon fichier via l'interface graphique, j'obtiens le bon résultat par GET:

{..."properties":{..."files:files":[{"file":{"name":"xxx.pptx","mime-type":"application/vnd.openxmlformats-officedocument.presentationml.presentation","encoding":null,"digest":"38a5173d02640809cae56ba36cd023d9","length":"291048","data":"files/8283131e-d835-4648-9bac6a662af950f5?path=%2Ffiles%2Fitem%5B0%5D%2Ffile"},"filename":"xxx.pptx"}]}}

ma configuration Nuxeo:

studio     started      atrium (id: atrium-0.0.0-SNAPSHOT)
hotfix     started      nuxeo-5.8.0-HF01 (id: nuxeo-5.8.0-HF01-1.0.0)
hotfix     started      nuxeo-5.8.0-HF02 (id: nuxeo-5.8.0-HF02-1.0.0)
hotfix     started      nuxeo-5.8.0-HF03 (id: nuxeo-5.8.0-HF03-1.0.0)
hotfix     started      nuxeo-5.8.0-HF04 (id: nuxeo-5.8.0-HF04-1.0.0)
hotfix     started      nuxeo-5.8.0-HF05 (id: nuxeo-5.8.0-HF05-1.0.0)
hotfix     started      nuxeo-5.8.0-HF06 (id: nuxeo-5.8.0-HF06-1.0.0)
hotfix     started      nuxeo-5.8.0-HF07 (id: nuxeo-5.8.0-HF07-1.0.0)
hotfix     started      nuxeo-5.8.0-HF08 (id: nuxeo-5.8.0-HF08-1.0.0)
hotfix     started      nuxeo-5.8.0-HF09 (id: nuxeo-5.8.0-HF09-1.0.0)
 addon     started      in2p3-atrium (id: in2p3-atrium-1.1.5)
 addon     started      nuxeo-dm (id: nuxeo-dm-5.9.2)
 addon     started      nuxeo-drive (id: nuxeo-drive-1.3.2)
 addon     started      nuxeo-rest-api (id: nuxeo-rest-api-5.8.0)

Qui peut m'aider à trouver l'erreur?

Cordialement Christian

2 REPLIES 2

Antoine_Cordier
Star Contributor
Star Contributor

Hello,

What is used in your curl command is:

"-H X-File-Idx:xxx.pdf" -H "X-File-Name:0"

While it should be "-H X-File-Idx:0" -H "X-File-Name:xxx.pdf"

Hope this helps,

Arnault_
Confirmed Champ
Confirmed Champ

Merci beaucoup

et ... désolé pour le dérangement ... que j'aurais pu éviter en relisant mieux!!!

Cordialement Christian

Getting started

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.