Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override Content Disposition Type for Attachments Opened Through xPages URLs

Tags:

xpages

Is there a way to override the content disposition header for an attachment opened through an xPage URL? I am attempting to open attachments/pdf's in the browser as opposed to the default which is to download/save.

This question was also asked on Wissel's site by Mark Leusink, but I couldn't find an answer.

like image 627
Patrick Sawyer Avatar asked Oct 19 '25 13:10

Patrick Sawyer


1 Answers

There are two approaches you can take:

  • Use an XAgent to read the attachment stream instead of linking to the attachment directly. There you can use the following to overwrite attachment/inline and file name.
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("content-disposition", "inline; Filename=invoice.pdf");
  • Be nice to your admin and use a web site rule to overwrite the HTTP header for your attachment urls. No code change in your application required and can be on a per application base

HTH :-) stw

like image 115
stwissel Avatar answered Oct 22 '25 09:10

stwissel