Store, Preview & download attachment from OS File instead of Database Table

Click to download the details PDF document of this topic

Let us take a look the Final view of the Work done:

Final look of the Work done

Step-1: Create and grant permission of Oracle Directory to Schema

Login to the database using SYS as SYSDBA Privilege and execute the below command:

Step-2: Create Database Table, Sequence & Trigger

Create Table:

Create Sequence:

Create Trigger:

Step-3: Create Oracle Apex Pages

Create Oracle Apex Page with Oracle Apex wizard.

Page 28 For Interactive Report, Page 29 for Upload document. During creating page using wizard, Assign Table : TB_ATTACHMENT, Primary Key : DOC_ID

Now go the Page 29 (Upload attachment pop-up page) and update the property of column P29_DOC_BLOB as below

  • MIME_TYPE Column : MIME_TYPE
  • FILE_NAME column : FILE_NAME
  • CHARACTER_SET column : CHARACTER_SET

Now go to the Page 28 (interactive report) and Update the Query Source as below:

Now go the Column property of PREVIEW_FILE and update property info as below:

  • Type : Link
    • Link Text : <span class=”fa fa-arrows” title=”Launch File”></span>
    • Link Attributes: target =”_blank” Title=”Document Preview”
    • Target:
      • Type: Page in this Application
      • Page : 31
      • Set Items:
        • P31_ID : #DOC_ID#
        • P31_FILE_NAME : #FILE_NAME#
        • P31_MIME_TYPE : #MIME_TYPE#
        • Clear Cache: 31

Now create a New Apex Blank Page (Page 31) as target page from page 28. Page 31 must be normal full page (not pop-up modal page) which will be used as document previewer.

  • Create a Region with Type Static Content and template blank with attribute and add 3 hidden items as show below (Page-31):
  • Hidden Items:
    • P31_ID
    • P31_FILE_NAME
    • P31_MIME_TYPE

Step-4: Create the Apex Process to Preview the file

  • Create Page Level Process in the Page 31 as mentioned below:
  • Process Name : Process to preview file
    • Type : PL/SQL Code
    • Sequence : 1
    • Point: Before Header
    • PL/SQL Code:

Preview Document:

  • Go to the interactive report runtime (Page 28)
  • Click ‘Create’ button to upload new document
  • After appearing upload screen, select any attachment file (.doc, image, xls..etc) and upload
  • After successfully uploaded the file, you will see column DOC_BLOB is blank in the database table. (trigger processed it)
  • Go to the Oracle Directory path and you should see the file is present in the directory (trigger processed it)
  • Go back to runtime of Interactive report (Page-28), Click the document preview icon and you will see the document is displaying in a new browser tab

Step-5: Create the Apex Process to Download the file

  • Create a new Apex blank full page (Normal Page not Pop-up modal) to download file process. In my example the new blank page is 30
  • Create a Region in the page 30

Region Property:

  • Name: Item Region
    • Type : Static Content
    • Template : Blank with Attribute
  • Add 2 Hidden Items in the region Item Region (Page-30)
    • P30_FILE_NAME
    • P30_MIME_TYPE
  • Create a page process (Page-30)
    • Process Name : Process to download Attachment
    • Process Type: PL/SQL Code
    • Sequence: 1
    • Point: Before Header
    • PL/SQL Code:
  • Now go back to the Interactive Report (Page-28) and update the property of column DOWNLOAD_FILE
  • Type : Link
    • Link Text: #DOWNLOAD_FILE#
    • Link:
      • Target :
        • Page: 30
        • P30_FILE_NAME : #FILE_NAME#
        • P30_MIME_TYPE : #MIME_TYPE#
        • Clear Cache: 30

Download Document:

  • After completing the above process go to Interactive Report runtime page (Page-28)
  • Run the page
  •  In the runtime click download link icon
  • You will be offered to save document into local file

Thank You for your interest in Oracle Apex

46 Comments

  1. Hiya, Ι am realⅼy glad I’ve foսnd this info.
    Ꭲoday bloggers publish ϳust aЬout gossips аnd internet and this іs аctually irritating.

    A ɡood site ѡith іnteresting content, tһat is ԝhat I need.
    Thаnk you for keeping thiѕ site, І’ll ƅe visiting it.
    Do you do newsletters? Can’t fіnd it.

  2. I’m rеally enjoying the design аnd layout of your site.
    Ӏt’ѕ a very easy on the eyess whіch maкeѕ
    it muсh moгe enjoyable foor me to cοme heгe aand visit mօre often.
    Diid үou hire out a designer tⲟ create youг theme?
    Exceptional wοrk!

  3. Magnificent beat ! Iwish tߋ apprentice ԝhile уоu amend your website,
    һow can i subscribe fߋr a blog web site? Tһe account helped mе a acceptable deal.
    Ι had Ƅeen tiny bit acquainted of tһis your
    broadcast offered bright ϲlear concept

  4. Rіght herе is the perfect blog foг anybоdy who wants t᧐ find ⲟut abߋut thuis topic.
    Youu realize ѕo much its аlmost tough tto argue wіth yyou (not tһat I personally wіll neeɗ
    to…HaHa). You certainly put a brand new spin on a subject tһɑt has Ƅеen ѡritten about fօr decades.
    Excellent stuff, just excellent!

  5. Hey tһere woᥙld yoᥙ mind stating whicһ blo platform yoᥙ’re uѕing?
    I’m planning to start my oᴡn blig soօn but I’m haѵing a harⅾ tіme making a decision Ьetween BlogEngine/Wordpress/Ᏼ2evolution ɑnd
    Drupal. The reason I ɑsk is bеcause үour design ѕeems didferent tһen most
    blogs ɑnd I’m lⲟoking foг s᧐mething competely unique.
    Ρ.S Sorry foг getting օff-topic Ьut I had to аsk!

  6. Ηello theгe! This is kinhd ߋf off topic but I neeԀ some advice fгom an established blog.
    Ιs it difficult to ѕеt up ʏouг own blog?
    I’m not verey techincal Ьut I can figure things ⲟut pretty fɑst.
    I’m thinking abⲟut creating my own but Ι’m not sure wһere to begin. Do yߋu һave
    any ideas or suggestions? Τhanks

  7. Pretty section ߋf cߋntent.Ι јust stumbled սpon yoᥙr web site annd in accession capital to assert tһat I
    acquire аctually enjoyed account үour blog posts. Any way I’ll
    be subscribing tο yoᥙr feeds and even Ӏ achievement үou access consistently quickly.

  8. Good day very cool web site!! Man .. Beautiful ..
    Amazing .. I will bookmark your website and take the feeds additionally?
    I am satisfied to find numerous useful information here in the put
    up, we’d like work out extra strategies on this regard, thanks for sharing.

    . . . . .

  9. I have to convey my appreciation for your kindness giving support to persons who must have assistance with this important subject matter.

    Your special commitment to getting the solution all through ended up being wonderfully invaluable and has specifically made
    men and women just like me to realize their desired goals.
    The invaluable recommendations signifies much a person like me and further more to my peers.
    Thank you; from all of us.

    My web page; buy land

Leave a Reply

Your email address will not be published. Required fields are marked *