RE: How make download link for document in liferay 7.2

Bhargav Vaghasiya, modified 4 Years ago. New Member Posts: 5 Join Date: 12/9/20 Recent Posts

Hello,

I am using Liferay 7.2 for one of my projects.

We are working emails section of our project in which we need to send an email with one download link. 

When the user clicks on the link, one zip file will be download. (File will be on /temp folder od in document&media library)

The download link will be valid for 1 day and then we need to show the expiration message on the screen.

How can we achieve this? please suggest.

We have tried the following way.

struts in Liferay: but it only working with URL starts with "/c/....". if we make a URL like this, it asks for login first (We need to download without login).

We checked to set an expiration time on a document in the document&media section and give the download link from there, but we can not set the expiration time in the document and media.

Can you please suggest best possible way to achieve this? thank you in advance

thumbnail
Mohammed Yasin, modified 4 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi,

As every document is an asset , you can try setting expiration date in asset entry for respected document. Then you can  have a service wrapper for DLAppService  and check the document expiration date from asset entry service. 

 

thumbnail
Fernando Fernandez, modified 4 Years ago. Expert Posts: 401 Join Date: 8/22/07 Recent Posts

If you are doing MVC Java portlets you can:

  1. Generate a uuid for each email you send, merge it with the serveResource URL of a portlet, include that in the email
  2. Store the uuid on a serviceBuilder table with the expiry date
  3. When a user clicks on the link, your portlet serveResource will get the uuid, check if it's valid, get the file and send it to the browser

HTH

Fernando