How to download files from the database file system
Hello everyone.
I´m trying to make a procedure to download a PDF file stored in the server file system of the database, and not inside the database. The procedure created is this:
create or replace
PROCEDURE PRT_PR_DOWNLOAD_FICH(v_file_name VARCHAR2
)
AS
v_length Number;
Lob_loc Bfile;
BEGIN
Lob_loc := bfilename('DIR_OBJ', v_file_name);
v_length := dbms_lob.getlength(Lob_loc);
owa_util.mime_header('application/octet', False);
htp.p('Content-length: ' || v_length);
htp.p('Content-Disposition: attachment; filename="' || SUBSTR(v_file_name, INSTR(v_file_name, '/') + 1) || '"');
owa_util.http_header_close;
wpg_docload.download_file(Lob_loc);
END PRT_PR_DOWNLOAD_FICH;
This procedure receive the name of the file to download and use the function wpg_docload.download_file(). The DIR_OBJ is a directory object with path in the server to the folder with the files i want to download.
I want to allow users to download PDF files stored in the database server file system, opening a Save/ Open window in the browser whenever the user click in a button. When the user click the button, the procedure is called and executed without any error but the Save/ Open window doesn't appear, instead the page it's simply reloaded, nothing happens.
Can anyone tell me what i am doing wrong and if this is the best way to download a file directly from the database server file system?
Best Regards Pedro