Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Satish Babu Anupoju
How to download PDF from Liferay 6.1 document library
17. April 2012 01:50
Antwort

Satish Babu Anupoju

Rang: Junior Member

Nachrichten: 66

Eintrittsdatum: 19. Februar 2011

Neue Beiträge

Hi Friends


Currently I am working with Liferay 6.1.
As per my requirement I have to upload bunch of all types of documents(like .txt, .doc, .pdf etc.,)

I am successfully uploading all the documents, But when I am trying to download, especially pdf and jpeg it is not giving any popup(like open and save ) and opening in the same window. It's not happening for remaining file extensions.


As per my requirement When I click on the download I want to ask one popup (link open and save ).

Can any one provide some suggestions to solve this issue.


Thanks in advance

Regards
Satish Babu
David H Nebinger
RE: How to download PDF from Liferay 6.1 document library
17. April 2012 07:47
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11464

Eintrittsdatum: 1. September 2006

Neue Beiträge

Your browser is determining that it can handle the display of the PDF which is why it is not prompting.

I believe there are headers that you can set to force the download, but you'll have to google for that information. Note that I do not believe there is a standard cross-browser solution.
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
25. April 2012 03:40
Antwort

Sharath Babu A

Rang: Regular Member

Nachrichten: 146

Eintrittsdatum: 18. Mai 2009

Neue Beiträge

Hi David H Nebinger,

Could you please be more clear, as even i am also looking for the same..


Regards,
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
25. April 2012 06:42
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7949

Eintrittsdatum: 23. März 2010

Neue Beiträge

Well, it's possible to download pdf file by right clicking on "Download" and selecting "Save target as..."

Or set the following property in portal-ext.properties
mime.types.content.disposition.inline=flv,swf,wmv
Ravi Kumar Gupta
RE: How to download PDF from Liferay 6.1 document library
25. April 2012 07:40
Antwort

Ravi Kumar Gupta

Rang: Liferay Legend

Nachrichten: 1303

Eintrittsdatum: 23. Juni 2009

Neue Beiträge

There is one more thing. Reading that should be useful. http://www.jguru.com/faq/view.jsp?EID=252010
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
25. April 2012 16:41
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7949

Eintrittsdatum: 23. März 2010

Neue Beiträge

In other words, to use
portal-service/src/com/liferay/portal/kernel/servlet/ServletResponseUtil.java

to call #531
protected static void setHeaders(
HttpServletRequest request, HttpServletResponse response,
String fileName, String contentType) {


even though, it's just doing this

String extension = GetterUtil.getString(
FileUtil.getExtension(fileName)).toLowerCase();

String[] mimeTypesContentDispositionInline = null;

try {
mimeTypesContentDispositionInline = PropsUtil.getArray(
"mime.types.content.disposition.inline");
}
catch (Exception e) {
mimeTypesContentDispositionInline = new String[0];
}

if (ArrayUtil.contains(
mimeTypesContentDispositionInline, extension)) {

contentDisposition = StringUtil.replace(
contentDisposition, "attachment; ", "inline; ");
}

response.setHeader(
HttpHeaders.CONTENT_DISPOSITION, contentDisposition);
}
Ravi Kumar Gupta
RE: How to download PDF from Liferay 6.1 document library
25. April 2012 20:53
Antwort

Ravi Kumar Gupta

Rang: Liferay Legend

Nachrichten: 1303

Eintrittsdatum: 23. Juni 2009

Neue Beiträge

Thanks Hitoshi for sharing the code snippet. I was thinking the same but just was lazy enough to look into it. emoticon And its good to know that Liferay is taking care by itself.
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
26. April 2012 04:42
Antwort

Sharath Babu A

Rang: Regular Member

Nachrichten: 146

Eintrittsdatum: 18. Mai 2009

Neue Beiträge

Hi Hitoshi,

Thanks for sharing your idea. What ultimately we need a popup to download the pdf & jpeg files.

If it is possible with hooks, Could you please explain me with more clear steps, So that i can do the same in my machine.


Regards,
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
26. April 2012 04:48
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7949

Eintrittsdatum: 23. März 2010

Neue Beiträge

This is just for pdf.

Just set the following property in portal-ext.properties:

mime.types.content.disposition.inline=flv,swf,wmv
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
26. April 2012 05:52
Antwort

Sharath Babu A

Rang: Regular Member

Nachrichten: 146

Eintrittsdatum: 18. Mai 2009

Neue Beiträge

I have already set the properties in portal-ext.properties. But didn't found any luck.

Thanks for prompt response.

Regards,
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
26. April 2012 05:55
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7949

Eintrittsdatum: 23. März 2010

Neue Beiträge

Can you tell me which browser and version you're using? Right click on the "Download" doesn't work either?
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
26. April 2012 21:28
Antwort

Sharath Babu A

Rang: Regular Member

Nachrichten: 146

Eintrittsdatum: 18. Mai 2009

Neue Beiträge

Hi Hitoshi,

I am able to right click on the "download" and "saveAs". But i need is a popup should open as its opening while downloading txt,ppt,doc etc.


Regards,