Page 1 of 1

Downloading PDFs using WAMS

Posted: Fri May 18, 2018 12:06 pm
by soa
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?

Re: Downloading PDFs using WAMS

Posted: Fri May 18, 2018 2:02 pm
by AbelS
Don't set the attachment file name.

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

HTH

Re: Downloading PDFs using WAMS

Posted: Fri May 18, 2018 2:52 pm
by soa
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.

Re: Downloading PDFs using WAMS

Posted: Mon May 21, 2018 12:01 pm
by AbelS
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.

Re: Downloading PDFs using WAMS

Posted: Mon May 21, 2018 2:37 pm
by soa
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).

Re: Downloading PDFs using WAMS

Posted: Mon May 21, 2018 5:51 pm
by soa
AbelS

That works beautifully! Thanks again for the help.