AnsweredAssumed Answered

Forcing a download of common mimetypes (xls, csv, txt)

Question asked by sgomez on Aug 28, 2009
Latest reply on Feb 3, 2015 by mdavid.cu
Hello,  I've looked all over for an answer to my question and have been unsuccessful thus far.  The wiki pages helped in giving me a better understanding of how to output my template through the browser, but not as an attachment that can be downloaded.  The closest I've come to an answer is from the following thread: http://forums.alfresco.com/en/viewtopic.php?f=36&t=14134&p=46633&hilit, although this topic was for a different file type (xls) which required adding a custom mimetype dfinition.  In my case, I want to give the user the option to download the output as a textfile. 

Is there a way to add a header file to a freemarker template so I can allow the user to download the output result of my template as text or any other common mimetype?  Thanks in advance.

My code is below and it works fine, I just don't know how to add a header to it.

Result: ${total} found
   <#list nodes as document>
      <#if document.isDocument>
                   {"name": "${document.name}"
         <#if document.properties.author??>, "author":"${document.properties.author}"</#if>
         <#if document.properties.creator??>, "creator":"${document.properties.creator}"</#if>
         <#if document.properties.modified??>, "modified":"${document.properties.modified?datetime}"</#if>
         <#if document.properties.created??>, "created":"${document.properties.created?datetime}"</#if>
         <#if document.properties.description??>, "description":"${document.properties.description}"</#if>
      </#if>
</#list>

Outcomes