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.
When i run this procedure i get the error: 'Internal Server Error'.
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?