Giovanni's logo
Sending a stream file to the browser
(download a stream file)
this means Version 2
index
M
power search
blue line

On Dec 30, 2012, CGISRVPGM2 has been added subprocedures DspStmf() and DnlStmf(). Both procedures are sending a specified stream file to the browser, but are slightly different.
  • Subprocedure DspStmf() (Display a stream file) leaves to the browser the decision whether to display or to download the stream file. Usually a browser decides to display a stream file if it has a pluging to do it (as an example, Internet Explorer has a pluging to display a PDF), otherwise it downloads the stream file (asks the user whether to open the stream file with the appropriate program or to save it).
  • Subprocedure DnlStmf() (Download a stream file) forces the browser to download the stream file (the browser asks the user whether to open the stream file with the appropriate program or to save it).
  • The extension of the stream file to be displayed can be any of the ones supported by the WEB browser(examples: .htm, .html, .txt, .jpg, .png, .xls, .xlsx, .doc, .docx, .pdf, ...)
  • The stream file displayed by procedure dspstmf() can be already existing or dynamically created by the CGI program ( example: through procedure WrtHtmlToStmf() )
  • one significant advantage could be that the URL of the stream file is not displayed, as just the url of the CGI program shows up.

Coding examples:
D xstmf           s           1024    varying
D rc              s             10i 0
 /free
      xstmf='/cgidev/favicon.ico';
      rc=DspStmf(xstmf);
      // OR
      rc=DnlStmf(xstmf);

      // rc is 0 when successful, -1 when failed 
In case of failure, check the joblog and/or the CGIDEBUG file for a detail error message.

You may try CGI program stmfToBrow which takes advantage of subprocedures DspStmf and DnlStmf.

Note - Since March 13, 2016 procedures DspStmf() and DnlStmf() can handle stream files even larger than 16 MB.