Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Mohammad.

Asked: October 11, 2024 - 12:31 pm UTC

Last updated: October 28, 2024 - 5:07 am UTC

Version: Oracle Apex 24.1

Viewed 100+ times

You Asked

Dear all,

I would like to download files from file server and view it in oracle apex. Till now I am unable to do so.

I have been able to export file, uploaded from a page oracle apex to file server but I would like also to do the other way round i.e. to read files from fileserver and view it in oracle apex.
Note that I am saving only file Id and filename in an oracle table.
The objective in doing this is that I would like to avoid saving files as BLOB in Database.

Thanking you,

and Connor said...

As long as the database has the ability to access those files (eg via a CIFS or NFS share) then you could download them via BFILE access, eg

declare
   l_file bfile := bfilename('MYDIR','myfilename');
   l_length  number := dbms_lob.getlength(l_file);

begin
   sys.htp.init();
   sys.owa_util.mime_header(
      'application/octet',
      false
   );

   sys.htp.p('Content-Length: ' || l_length);
   sys.htp.p('Content-Disposition: attachment; filename="' || l_name || '"; filename*=UTF-8''''' || l_name);
   
   sys.owa_util.http_header_close;
   sys.wpg_docload.download_file(l_file);
   apex_application.stop_apex_engine;
end;


More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here