No popup screen using wpg_docload.download.

ifnanton
ifnanton used Ask the Experts™
on
To download with OAS, executing htp.download made appear a popup screen with a question what to do with the data. So you could save the data to a file on the network.
After migrating to 9iAS, htp.download is replaced by wpg_docload.download. Executing that statement causes the data to appear on the webpage. Is it possible to get my popup screen back???
A workaround is to use the option 'View Source', which will put the data in a notepad screen. The volume of the data is sometimes more than 2 mb. Most of the time, 2mb doesn't fit in notepad.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
You may do something like that:

 create or replace procedure download_blob(v_id NUMBER)
 is
 myblob blob;
 begin
 select col_blob into myblob from blob_table where id=v_id;
-- may be another type
 htp.p('Content-Type: text/html');
 htp.p('Content-Length: ' || dbms_lob.getlength(myblob));
-- start open/save dialog in IE
htp.p('Content-Disposition: attachment;filename=test.txt');
 owa_util.http_header_close;
-- download file
 wpg_docload.download_file(myblob);
 end;
 
Best regards,
Lucy
Commented:
It took me some time to get back to you, but with the help of Oracle, the working solution is this:

create or replace procedure download_blob(v_id NUMBER)
is
myblob blob;
begin
select col_blob into myblob from blob_table where id=v_id;
owa_util.mime_header('application/unknown', FALSE);
htp.p('Content-Length: ' || dbms_lob.getlength(myblob));
owa_util.http_header_close;
-- download file
wpg_docload.download_file(myblob);
end;

You have to specify an unknown mime-type in order to get the popup screen. If the mime-type is known, the browser will open the file with the application specified in the mime-type, i.e. application/pdf.

Regards,
Anton
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[PAQ with points refunded]
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

MathiasMagnusson
EE Cleanup Volunteer

Commented:
I don't know if this thread is still open but the answer is to addthe following to the http header

    htp.p('Content-Disposition: attachment; filename="' || p_which_file || '.html"');

This will get you your open/save dialog box

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial