WebScript to retrieve the content of a given document?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 04:33 AM
Is there a default Web Script that allows to retrieve - as the native byte stream with MIME-type - the content of a document?
Is it mabye the following?
http://localhost:8080/alfresco/service/api/node/content{;property}/{store_type}/{store_id}/{node_id}...?}
This seems useful to retrieve a property (title, creator, desccription…), I'm not sure if it will return the actual content of the document stored in the node (my content repository will contain Office documents, pictures, etc.).
Is it mabye the following?
http://localhost:8080/alfresco/service/api/node/content{;property}/{store_type}/{store_id}/{node_id}...?}
This seems useful to retrieve a property (title, creator, desccription…), I'm not sure if it will return the actual content of the document stored in the node (my content repository will contain Office documents, pictures, etc.).
Labels:
- Labels:
-
Archive
7 REPLIES 7

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 01:44 PM
yes that is it
For example to get a url for viewing back from a webscript in a ftl file where d is a script node for a doc
${absurl(url.serviceContext)}/api/node/content/${d.nodeRef.storeRef.protocol}/${d.nodeRef.storeRef.identifier}/${c.nodeRef.id}/${c.name?url}
from flexspaces integratedsemantics/folderlist/folderlist.get.xml.ftl web script
the ?url in the name is to encode any spaces etc in the name
to get mimetype you can use
d.mimetype
Steve
For example to get a url for viewing back from a webscript in a ftl file where d is a script node for a doc
${absurl(url.serviceContext)}/api/node/content/${d.nodeRef.storeRef.protocol}/${d.nodeRef.storeRef.identifier}/${c.nodeRef.id}/${c.name?url}
from flexspaces integratedsemantics/folderlist/folderlist.get.xml.ftl web script
the ?url in the name is to encode any spaces etc in the name
to get mimetype you can use
d.mimetype
Steve

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 01:53 PM
Thanks Steve for the response.
I know that FlexSpaces does exactly what we're trying to do in our custom application (for a customer, we need to develop a custom web client, muuuuch simpler and less interactive than FlexSpaces
).
Can you provide a basic example of the WebScript URL syntax that should be used?
I've not understood at all how we should use the ?url parameter and how to be sure to receive the document in it's native format… you mention a "ftl file" but I don't understand what you mean with this.
I've also not understood the meaning of the optional a={attach?} parameter…
I know these are classic questions from a newbie, and I know that you've been working on FlexSpaces for months so now you're very familiar with the development of applications that use JavaScript-based and Java-backed Web Scripts…
I know that FlexSpaces does exactly what we're trying to do in our custom application (for a customer, we need to develop a custom web client, muuuuch simpler and less interactive than FlexSpaces

Can you provide a basic example of the WebScript URL syntax that should be used?
I've not understood at all how we should use the ?url parameter and how to be sure to receive the document in it's native format… you mention a "ftl file" but I don't understand what you mean with this.
I've also not understood the meaning of the optional a={attach?} parameter…
I know these are classic questions from a newbie, and I know that you've been working on FlexSpaces for months so now you're very familiar with the development of applications that use JavaScript-based and Java-backed Web Scripts…

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 03:07 PM
ftl = freemarker template
?url is a freemarker builtin to escape character in the file name on a url, not anything about the content itself
http://freemarker.org/docs/ref_builtins_string.html
What I showed before was example in a webscript that you call and gives you back a url
If you just want to call the url assuming you have something in the main "company home" store and not in a avm or 3.0 collab site:
{http}://{host}:{port}/alfresco/service/api/node/content/workspace/SpacesStore/{node_id}/{node_name_encoded}
the optional a=true attachment arg will do the following in the java code for the webscript
// set header based on filename - will force a Save As from the browse if it doesn't recognize it
// this is better than the default response of the browser trying to display the contents
httpRes.setHeader("Content-Disposition", "attachment");
PS Components from FlexSpaces can be used to have a simpler ui. Also I going to work on allowing you to make things simpler or different, view columns, properties for custom types, via xml configuration.
Steve
?url is a freemarker builtin to escape character in the file name on a url, not anything about the content itself
http://freemarker.org/docs/ref_builtins_string.html
What I showed before was example in a webscript that you call and gives you back a url
If you just want to call the url assuming you have something in the main "company home" store and not in a avm or 3.0 collab site:
{http}://{host}:{port}/alfresco/service/api/node/content/workspace/SpacesStore/{node_id}/{node_name_encoded}
the optional a=true attachment arg will do the following in the java code for the webscript
// set header based on filename - will force a Save As from the browse if it doesn't recognize it
// this is better than the default response of the browser trying to display the contents
httpRes.setHeader("Content-Disposition", "attachment");
PS Components from FlexSpaces can be used to have a simpler ui. Also I going to work on allowing you to make things simpler or different, view columns, properties for custom types, via xml configuration.
Steve

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 03:41 PM
ftl = freemarker template
Yes, I know… but what I did not understand was the need of using a Freemarker script within the Web Script. Are you talking about a custom Web Script? In this case, could you post the whole Web Script implementation (definition, .js and .ftl files) so I'll understand the overall logic? That would be great…
Or maybe you were talking about one of the built-in web scripts, but in this case I'm a bit lost…
What I showed before was example in a webscript that you call and gives you back a url
If you just want to call the url assuming you have something in the main "company home" store and not in a avm or 3.0 collab site:
{http}://{host}:{port}/alfresco/service/api/node/content/workspace/SpacesStore/{node_id}/{node_name_encoded}
Ok, this looks exactly what I need. With {node_name_encoded} you mean the document name attribute?
Is there a way to pass the document unique node id?
the optional a=true attachment arg will do the following in the java code for the webscript
// set header based on filename - will force a Save As from the browse if it doesn't recognize it
// this is better than the default response of the browser trying to display the contents
httpRes.setHeader("Content-Disposition", "attachment");
Ok, this makes sense… useful.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 03:58 PM
"Or maybe you were talking about one of the built-in web scripts" (in the builtin sample webscript package) see folder.get.html.ftl
http://wiki.alfresco.com/wiki/Web_Scripts_Examples#Folder_Browse.2FRSS_Feed
"Ok, this looks exactly what I need. With {node_name_encoded} you mean the document name attribute?" yes
"Is there a way to pass the document unique node id?" need to pass both node id and node name
http://wiki.alfresco.com/wiki/Web_Scripts_Examples#Folder_Browse.2FRSS_Feed
"Ok, this looks exactly what I need. With {node_name_encoded} you mean the document name attribute?" yes
"Is there a way to pass the document unique node id?" need to pass both node id and node name
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2008 07:27 AM
Hi,
can anyone please give a sample url to retrieve the content of a document. how do we know the node id,store id, store type and property..?
http://localhost:8080/alfresco/service/api/node/content{;property}/{store_type}/{store_id}/{node_id}...?}
can anyone please give a sample url to retrieve the content of a document. how do we know the node id,store id, store type and property..?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2009 05:56 AM
Hi Madhu,
You need to get hold of "node". This you can get by the help of lucene to your file in the repository. Then you can use following syntax to download the file
Thanks
Kayan
You need to get hold of "node". This you can get by the help of lucene to your file in the repository. Then you can use following syntax to download the file
http://localhost:8080/alfresco/service/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nod...
Thanks
Kayan
