This question is an exact duplicate of:
- File is not downloading from server 3 answers
I am using Struts2 and Liferay for developing an application.
My struts.xml
is as follows:
<action name="download" class="com.stp.portal.view.DownloadAction">
<result name="success" type="stream">
<param name="contentType">application/pdf</param>
<param name="inputName">fileInputStream</param>
<param name="contentDisposition">attachment;filename="abc.pdf"</param>
<param name="bufferSize">1024</param>
</result>
</action>
I basically want to download a pdf file from the server. But I get the following error:
10:05:55,782 ERROR [Jsr168Dispatcher:38] Could not execute action java.lang.IllegalArgumentException: application/pdf is not a supported mime type at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:159)...
Don't know how to resolve this. Would really appreciate someone's help. Really need this to be done.
Put
portletUrlType="resource"
to the<s:url>
tag which you use to create download link.Looking at the source code seems like only
application/vnd.wap.xhtml+xml
andtext/html
are allowed.Source: http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-impl/6.0.2/com/liferay/portlet/MimeResponseImpl.java