Downloading PDFs using WAMS

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
soa
Posts: 312
Joined: Mon Dec 07, 2015 3:15 pm

Downloading PDFs using WAMS

Post by soa » Fri May 18, 2018 12:06 pm

I'm using a WAM to download A PDF to a browser

Webroutine Name(get_File) Response(#http1

#http1.ContentFile := #filepath
#http1.AttachmentFileName := #docnam
#http1.ContentType := #mimetype

In the browser this downloads the document. I'd like it to open in another tab for the user to view rather than to download then open it.

I gather this behaviour is controlled by the content-disposition tag eg

Content-Disposition: attachment; filename=HTTP_Succinctly.pdf

I think I need to set this to :inline but I cannot see a way to do this.

Can it be done in LANSA?

AbelS
Posts: 27
Joined: Wed Nov 16, 2016 1:43 pm
Location: Sydney, Australia
Contact:

Re: Downloading PDFs using WAMS

Post by AbelS » Fri May 18, 2018 2:02 pm

Don't set the attachment file name.

To open in a new window set the show_in_new_window property to true.

HTH

soa
Posts: 312
Joined: Mon Dec 07, 2015 3:15 pm

Re: Downloading PDFs using WAMS

Post by soa » Fri May 18, 2018 2:52 pm

the Response object doesn't have a 'show_in_new_window property and if I don't set the file name property the user won't see the correct file name.

AbelS
Posts: 27
Joined: Wed Nov 16, 2016 1:43 pm
Location: Sydney, Australia
Contact:

Re: Downloading PDFs using WAMS

Post by AbelS » Mon May 21, 2018 12:01 pm

1. Instead of setting the attachment file name using #http1.AttachmentFileName := 'mydocname'
add the header yourself: #http1.AddHeader( 'Content-disposition', 'inline; filename=mydocname')

2. The 'show_in_new_window' property is a weblet property. Look at the std_lob weblet.

soa
Posts: 312
Joined: Mon Dec 07, 2015 3:15 pm

Re: Downloading PDFs using WAMS

Post by soa » Mon May 21, 2018 2:37 pm

Abels, thank you for that it makes sense. I've never used WAMs as they were originally designed - only as a way of delivering content (eg pdfs or json).

soa
Posts: 312
Joined: Mon Dec 07, 2015 3:15 pm

Re: Downloading PDFs using WAMS

Post by soa » Mon May 21, 2018 5:51 pm

AbelS

That works beautifully! Thanks again for the help.

Post Reply