cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a blob image with cURL?

Édouard_Mercier
Champ on-the-rise
Champ on-the-rise

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

1 ACCEPTED ANSWER

Wojciech_Sulejm
Star Contributor
Star Contributor

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

View answer in original post

6 REPLIES 6

Wojciech_Sulejm
Star Contributor
Star Contributor

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

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

Édouard_Mercier
Champ on-the-rise
Champ on-the-rise

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-70...
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...

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.

Right the "Content-Type" is misleading and unnecessary.

Florent_Guillau
World-Class Innovator
World-Class Innovator

Why the `Content-Type