cancel
Showing results for 
Search instead for 
Did you mean: 

How to download a file from Repository through java?

v317173
Champ in-the-making
Champ in-the-making
I am using alfresco to act as a file transfer hub between various application.
Now I want to customize an action which can ftp or copy the file to a target location outside of alfresco (it should a physical folder on OS level, not an alfresco virtual drive)
So I extend the class: ActionExecuterAbstractBase
I check the source:
http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/jav...
There is a method: public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef){ }
But I don't know how to use this Action and NodeRef to read file from repository.

Anyone can give a hint how to read file from alfresco repository? I just need to read a file from repository and store it locally.
1 REPLY 1

gyro_gearless
Champ in-the-making
Champ in-the-making
You might want to use ContentService to get a reader on the node's content:

ContentReader cr = contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);

and then use the obtained ContentReader for further processing:

File f = new File("/var/tmp/foo.bar");
cr.getContent(f);


See http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/repository/ContentSer... for full details  😎

HTH
Gyro
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.