How to get download link for document which is attached in task?

cancel
Showing results for 
Search instead for 
Did you mean: 
mitpatoliya
Moderator
Moderator

How to get download link for document which is attached in task?

I have some documents added as a part of process. Now I want to get download link of those documents in my backend task listener bean. How can I achieve that? I searched into apis of RelatedContentService of Activiti but could not get it.

I am using alfresco activiti enterprise 1.4

4 Replies
cjose
Senior Member II

Re: How to get download link for document which is attached in task?

If you are looking for the api to download the file, you can use 
GET api/enterprise/content/{contentId}/raw. For more details check https://docs.alfresco.com/activiti/docs/dev-guide/1.5.0/#_content

{contentId} can be obtained from the RelatedContentService API.

Regards,

Ciju

mitpatoliya
Moderator
Moderator

Re: How to get download link for document which is attached in task?

Yes Ciju, I am aware about that but if I have to get it in backend class(without hardcoding any part of the link) how do I get it? 

cjose
Senior Member II

Re: How to get download link for document which is attached in task?

I might not have understood the question correctly. The link itself is not stored anywhere in the database, it would need to be constructed in your task listener. Also, I'm not sure of the use case here, would you mind sharing the use case? Are you generating an email in the task listener with a link to the attachment?


The options that I am aware of are:

1) Via activiti-app UI (Cookie Based Authentication) - /activiti-app/app/rest/content/{contentId}/raw
2) api/enterprise/content/{contentId}/raw (Basic Authentication)
3) The third option is for you to write a Custom REST API on top of the relatedContentService API (https://docs.alfresco.com/activiti/docs/dev-guide/1.5.0/#_custom_rest_endpoints)

Regards,

Ciju

gdharley
Intermediate

Re: How to get download link for document which is attached in task?

Hi Mittal,

I think what you are really asking is, how, inside your task listener, can you "generate" the content links to the documents stored in the process instance. I imagine as part of your delegate service you are saving these URL's for another system, or something like that.


If this is the case, then what you really need is to recover the content ID's for the attached files as this is the only variable in the enterprise API to retrieve raw content.

The content ID for all documents associated with the process instance can be retrieved using the following REST API:

Alfresco Activiti - Enterprise REST Content 
e.g. http://localhost:8080/activiti-app/api/enterprise/process-instances/45025/content 


If you are looking for the Java equivalent you would use the RelatedContentService.

Check out the following forum post on how to use the RelatedContentService:

 

Cheers,

Greg