Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to download files from the database file system.

PedroMendezApr 6 2009 — edited Apr 7 2009
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?
This post has been answered by MatthiasHoys on Apr 7 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 5 2009
Added on Apr 6 2009
26 comments
3,473 views