Kbase 19797: Sample Program to Return .doc .xls .pdf files in WebSpeed
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/15/2008 |
|
Status: Verified
GOAL:
Sample CGI Wrapper procedure to return .doc .xls .pdf files in WebSpeed.
FACT(s) (Environment):
WebSpeed 3.x
FIX:
An example of a CGI wrapper procedure in Progress WebSpeed to return, in a web request, a .doc, .xls, .pdf, or any other document type instead of an HTML page.
The sample program uses the output-content-type statement to specify what type of document is being returned to the Web browser.
Example of content types:
-- Microsoft Excel .xls: application/x-msexcel
-- Microsoft Word .doc : application/msword
-- Portable Document Format .pdf: application/pdf
You can view content type (MIME) with the View/Options/File Types in the Windows Explorer or under Preferences/Navigator/Applications in the Netscape browser.
When the program is compiled to r-code, you can refer to the program using any extension since WebSpeed will search and find the .r before looking for the specific extension. For example, if you refer to the program testxls.xls from within WebSpeed, WebSpeed will search for testxls.r and, if found, executes it. Otherwise, WebSpeed tries to find and compile a file with the specified name.
NOTE: It is highly recommended not to use environment or CGI variables to refer to the file name in the program because any other file could be downloaded.
Sample program for a MS-Excel .XLS file:
/* testxls.p */
/* Do not use a CGI variable for the file name */
{src/web/method/wrap-cgi.i}
define stream infile.
define variable vdata as raw no-undo.
output-content-type("application/x-msexcel").
input stream infile from d:\docs\sample.xls binary.
length(vdata) = 20480.
repeat:
import stream infile unformatted vdata.
put {&WEBSTREAM} control vdata.
end.
length(vdata) = 0.
input stream infile close.
/* end of testxls.p */