Here I am giving an example to display the external file in a region in Oracle Apex.
In Oracle, you can access external files using the Oracle directory object. Suppose you have the external files on the server directory /oracle/usr/emp/docs
, then you should have a directory object created for this path. Below is an example of creating an Oracle Directory:
Create Directory emp_docs as '/oracle/usr/emp/docs'; Grant read, write on emp_docs to yourUsername;
Display External Files in a Region in Oracle Apex Example
Now to access the files from the above directory and display them in a region in Oracle Apex, create an Application Process as Ajax Callback and add the following PL/SQL code in it:
Ajax Application Process name: download_extfile.
Declare lob_loc Bfile; v_mime Varchar2(50) Default 'application/pdf'; vblob Blob; Begin lob_loc := BFILENAME (UPPER ('EMP_DOCS'), 'YourPDF.pdf'); vblob := to_blob(lob_loc); owa_util.mime_header( v_mime, false ); htp.p('Content-Length: ' || dbms_lob.getlength(vblob)); owa_util.http_header_close; wpg_docload.download_file(vblob); End;
The above PL/SQL code will get the file in the BFILE lob locator and then will convert it to BLOB so that it can be downloaded in the region.
After creating the Ajax callback process, create a region as URL type in your page, then click on the attribute tab, and in the URL field, paste the following URL:
f?p=&APP_ID.:0:&SESSION.:APPLICATION_PROCESS=download_extfile:NO
In the IFrame attribute field, paste the below code:
width="500" height="600"
You can set the height and width according to your needs.
Rohitmore11
Hi vinish,
Can we show MS word (.doc, .docx) , PPT or excel files using above method. I have table column where files are stored as blob.
Listening from you.
Thanks,
Rohit M.