How to get a blob image with cURL?

Hello.

We are Nuxeo ECM total rookies. We have defined a document model in our ECM instance, and this model contains a blob “illustration” attribute, which enables to store an image.

When looking at the rendering page which of that document model, when the blob attribute has been fulfilled with a picture, the image is diplayed in ECM with an hyperlink like “http://localhost:8080/nuxeo/nxfile/default/351993be-1ee6-43c1-b081-709a519f665c/as:illustration/image.png”.

We strive to download that image from the command line with cURL with the command 'curl -H 'Content-Type:application/json+nxrequest' -u:Administrator:Administrator “http://localhost:8080/nuxeo/nxfile/default/351993be-1ee6-43c1-b081-709a519f665c/as:illustration/image.png”', authenticated properly, but this command returns an empty stream. Eventually, we will achieve that download from a Java application, which cannot use the Automation client, because we run in a Google App Engine box.

However, we thought that we had followed the documentation available at “http://doc.nuxeo.com/display/NXDOC55/Using+cURL”, but we must have missed something. I need to mention that, if we open a browser with the URL “http://localhost:8080/nuxeo/nxfile/default/351993be-1ee6-43c1-b081-709a519f665c/as:illustration/image.png”, the browser proposes to open or save the file.

If someone could help us to work this out, we would be grateful. Thank you for your attention.

Regards, Édouard

0 votes

2 answers

15911 views

ANSWER

Why the Content-Type: application/json+nxrequest ?
05/23/2012



This is most probably because you have a syntax error in your command:

curl -H 'Content-Type:application/json+nxrequest' -u:Administrator:Administrator “http://localhost:8080/nuxeo/nxfile/default/351993be-1ee6-43c1-b081-709a519f665c/as:illustration/image.png”

Please note there should be a space instead of the colon between -u and Administrator to have the following instead:

-u Administrator:Administrator

1 votes



Thank you Wojciech. Shame on me, I must be too tired! It now works lit a charm. Regards, Édouard
05/23/2012


Just an after thought, running

curl -I -H 'Content-Type:application/json+nxrequest' "http://localhost:8080/nuxeo/nxfile/default/351993be-1ee6-43c1-b081-709a519f665c/as:illustration/image.png"

actually returns the right HTTP status,

HTTP/1.1 302 D?plac? Temporairement
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=5D57191A544CCA6D6BA5442672954DA8.nuxeo; Path=/nuxeo
Location: http://localhost:8080/nuxeo/login.jsp?requestedUrl=nxfile%252Fdefault%252F351993be-1ee6-43c1-b081-709a519f665c%252Fas%253Aillustration%252Fimage.png
Content-Length: 0
Date: Wed, 23 May 2012 07:31:22 GMT

which accounts for the credential issue ;) Maybe, a “forbidden” status would be better…

0 votes



This is done on purpose, we redirect to the login page so that an unauthenticated user that follows the link is asked to authenticate first.
05/23/2012

Right the "Content-Type" is misleading and unnecessary.
05/23/2012