cancel
Showing results for 
Search instead for 
Did you mean: 

retrieving an image from the repository using webscripts

emichbe
Champ in-the-making
Champ in-the-making
Hi,

I am trying to retrieve a picture from the repository using webscripts :
var image = search.findNode("workspace://SpacesStore/89636147-5c76-11dc-b969-3bdfab08a4b3");
model.imgContent = image.content;

Somehow, the content stored in model.imgContent is corrupt. The size is different than the original file.

How can I retrieve content in a correct way ?!
4 REPLIES 4

davidc
Star Contributor
Star Contributor
What are you trying to do with your image content? If you just want to write it back on the request, there's already a web script for doing that

http://wiki.alfresco.com/wiki/HTTP_API_Reference#Content_Retrieval

or the download servlet

http://wiki.alfresco.com/wiki/URL_Addressability#DownloadContentServlet

The javascript/template api's only allow access to the content as a string.

emichbe
Champ in-the-making
Champ in-the-making
The thing I would like to do is to generate a document, like with WordML, that contains the different images I would like to see in my document (checked with checkboxes in a custom view) using the javascript/template api.

davidc
Star Contributor
Star Contributor
Do you require the content to be embedded in your doc, or can you refer to the content via url?

The freemarker api provides a content download url e.g.

document.url;

emichbe
Champ in-the-making
Champ in-the-making
Should be embedded. I will try that and let you know.