I need to implement downloading a file from the page when I go to it.
On the page, the process is implemented in "Pre-Rendering" - "Before Header", but the recommended technique for implementing the file download does not work. The contents of the file are displayed on the page as an inline instead of downloading the file. I read about the problem of HTTP headers (mime) in version 5 of Apex and applied the recommendations in the code. But this does not work:
Sys.htp.flush;
Sys.htp.init;
Sys.owa_util.mime_header ('application/octet-stream', FALSE, 'UTF-8');
Sys.htp.p ('Content-length:' || sys.dbms_lob.getlength (v_file_body));
Sys.htp.p ('Content-Disposition: attachment; filename = "FILENAME.TXT"');
Sys.owa_util.http_header_close;
Wpg_docload.download_file (v_file_body);
Where "v_file_body" is a blob. In Apex 4.2, this technique worked fine and without the recommended "sys.htp.flush; sys.htp.init" for version 5. What am I doing wrong?
P.S: Sorry for the google translation ...