This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions
  • 7,916,821 Comments

Discussions

Display blob from database on Apex page

newjack
newjack Member Posts: 10 Red Ribbon
edited Jan 4, 2019 10:42AM in APEX Discussions

Hello,

In Apex 5, we have a requirement to have several documents stored as blobs in the database be displayed on an apex page somehow, possibly in a region with the <embed> tag.  Searching the forums hasn't revealed a solution. 

We tried using the common code snippet

SELECT doc_image, DBMS_LOB.GETLENGTH(doc_image), doc_filenameINTO v_blob , v_length, v_filenameFROM test_download_docWHERE doc_id = to_number(i_doc_id);---- set up HTTP header---- use an NVL around the mime type and -- if it is a null set it to application/octect-- application/octect may launch a download window from windowsowa_util.mime_header( nvl(v_mime,'application/pdf'), FALSE );-- set the size so the browser knows how much to downloadhtp.p('Content-length: ' || v_length);-- the filename will be used by the browser if the users does a save ashtp.p('Content-Disposition: inline; filename="'||replace(replace(substr(v_filename,instr(v_filename,'/')+1),chr(10),null),chr(13),null)|| '"');-- close the headers owa_util.http_header_close;-- download the BLOBwpg_docload.download_file( v_blob );end download_doc;

but that only resulted in the below when trying to render the pdf from the above approach.

bad_pdf.png

Any guidance would be appreciated.

Tagged:
Mohamed Haroun

Best Answer

Answers