AnsweredAssumed Answered

Sintax to download a file

Question asked by icarrara on Jan 25, 2008
Latest reply on Feb 27, 2008 by icarrara
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.

Outcomes