cancel
Showing results for 
Search instead for 
Did you mean: 

How to download an image to a local folder

fagomez
Champ in-the-making
Champ in-the-making
Hi everybody!

My problems is, that i need to copy and image from alfresco to a local folder,
i supposed that i need to use the method read, Does Anyone know how i can do it?

thanks a lot!
2 REPLIES 2

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Yes you are correct, you want to use the method read on the content web service.

This will give you a content object which contains a URL.  This URL points to the download servlet and if requested will return the content you are after.

See ContentUtils.java in the web service client project for some helper methods to do this.

Hope this helps,
Roy

jtorres
Champ in-the-making
Champ in-the-making
With the examples provides in the SDK is not difficult, use copyToFile method from ContentUtils:

Content[] readResult = contentService.read(new Predicate(
                                  new Reference[]{ref}, STORE, null),                                                        
                                  Constants.PROP_CONTENT);
Content content = readResult[0];
// Download file
ContentUtils.copyContentToFile(content, file);

Hope this helps you.