cancel
Showing results for 
Search instead for 
Did you mean: 

Sintax to download a file

icarrara
Champ in-the-making
Champ in-the-making
Hi all!

I wrote a Jsr168 portlet and deployed it in Liferay Enterprise Portal.

I wrote a Alfresco's Web Scrip to list files in a folder and download a file clicking on the Url.

Inside my portlet I'm able to list the names of binary files and view the content of text files.

The problem is that I'm not able to download the binary files.

Below the folder.get.html.ftl of the Web Script:
————————————————————
Folder: ${folder.displayPath}/${folder.name}
<br>
<table>
<#list folder.children as child>
<#if child.isDocument>
<tr><td>${child.properties.name}</td></tr>

<#if child.mimetype = "text/plain">
  <tr><td style='padding-left:16px'>${child.content}</td></tr>
<#else>

  <tr><td style='padding-left:16px'><a href="${absurl(child.downloadUrl)}?ticket=${session.ticket}">${child.downloadUrl}</a></td></tr>

  <tr><td style='padding-left:16px'><a href="${absurl(url.serviceContext)}/api/node/content/${child.nodeRef.storeRef.protocol}/${child.nodeRef.storeRef.identifier}/${child.nodeRef.id}/${child.name?url}?ticket=${session.ticket}">${child.name}</a></td></tr>

</#if>
</#if>
</#list>
</table>
————————————————————
As you can see, I tried two method to obtain the download Url:

In the first I get an "HTTP Status 404" error page that tell me that the requested resource is not available.

In the second I get the login request, because I'm asking to execute the Web Script "/api/node"

Note that in the two methods I add the "?ticket=${session.ticket}" directive.

I'm a bit confuse….

Please, could someone help my to construct the correct Url to download the bynary files?

Thank you in advance!

Ivano C.
2 REPLIES 2

kevinr
Star Contributor
Star Contributor
What do the generated URLs look like?

Kevin

icarrara
Champ in-the-making
Champ in-the-making
Hi Kevin!

Thank you for your reply but I solved my problem… It was my fault!

Web Script are faboulous!

Sincerely,
Ivano Carrara