Dan Packer
Member
I'm trying to download a pdf document via Webspeed. The document is available on the application server, but not on the web server, so I can't just link to it.
The code below (along with all other examples I can find on the web) just returns a web page with the headers, followed by the PDF code embedded in the browser. Does anyone have an idea as to what I'm missing?
Thanks for any help or advice you can provide!
-Dan
The code below (along with all other examples I can find on the web) just returns a web page with the headers, followed by the PDF code embedded in the browser. Does anyone have an idea as to what I'm missing?
Code:
<SCRIPT LANGUAGE="SpeedScript">
{src/web/method/wrap-cgi.i}
DEFINE STREAM infile.
DEFINE VARIABLE vdata AS RAW NO-UNDO.
/*
I've tried different variations on http-headers and content types, nothing seems to work :(
*/
output-http-header("Content-Description":U, "File Transfer":U).
output-http-header("Content-Type":U, "application/pdf":U).
output-http-header("Content-Transfer-Encoding":U, "binary":U).
output-http-header("Content-Disposition":U, SUBSTITUTE('attachment~;filename="&1"':U,
"Invoice0004.pdf")
).
OUTPUT-CONTENT-TYPE("application/pdf").
INPUT STREAM infile FROM /tmp/Invoice00004.pdf BINARY NO-ECHO NO-CONVERT NO-MAP.
LENGTH(vdata) = 338966.
REPEAT:
IMPORT STREAM infile UNFORMATTED vdata.
PUT {&WEBSTREAM} CONTROL vdata.
END.
LENGTH(vdata) = 0.
INPUT STREAM infile CLOSE.
</SCRIPT>
Thanks for any help or advice you can provide!
-Dan