Forum Stats

  • 3,759,506 Users
  • 2,251,555 Discussions
  • 7,870,687 Comments

Discussions

Download a BLOB image as file, how?

M.Emmanuel
M.Emmanuel Member Posts: 304
edited Sep 15, 2016 3:02AM in APEX Discussions

In APEX 5.0.3, Universal Theme, I would like to include a link in a report to download an image stored as BLOB in a table column.

I find references to APEX 4.x but not APEX5.0.5, what I want is a link that, when user clicks on, a "download file" with a given filename appears.

Any tip is welcomed, thanks,

PMONMike Kutzorpheus4192Runrig

Best Answer

  • fac586
    fac586 Senior Technical Architect Member Posts: 19,934 Red Diamond
    edited Sep 14, 2016 7:26AM Accepted Answer
    M.Emmanuel wrote:The report:
    pastedImage_0.png

    The report query:

    pastedImage_1.png

    The error:

    pastedImage_2.png

    Do not include the IMAGE in the report query projection. Whatever method is used to create the download link, the BLOB column is never directly selected in the report.

    Remove both instances of IMAGE from the projection, and alias the BLOB length column as IMAGE_DOWNLOAD.

    M.EmmanuelRunrig
«1

Answers

  • fac586
    fac586 Senior Technical Architect Member Posts: 19,934 Red Diamond
    edited Sep 13, 2016 11:08AM
    M.Emmanuel wrote:In APEX 5.0.3, Universal Theme, I would like to include a link in a report to download an image stored as CLOB in a table column.I find references to APEX 4.x but not APEX5.0.5, what I want is a link that, when user clicks on, a "download file" with a given filename appears.

    Why are you trying to store image data in a CLOB?

    Images are binary and should be stored as BLOBs.

  • M.Emmanuel
    M.Emmanuel Member Posts: 304
    edited Sep 13, 2016 2:28PM

    It was a typo, I mean BLOB.

  • fac586
    fac586 Senior Technical Architect Member Posts: 19,934 Red Diamond
    edited Sep 13, 2016 3:08PM
    M.Emmanuel wrote:In APEX 5.0.3, Universal Theme, I would like to include a link in a report to download an image stored as BLOB in a table column.I find references to APEX 4.x but not APEX5.0.5, what I want is a link that, when user clicks on, a "download file" with a given filename appears.
    M.Emmanuel wrote:It was a typo, I mean BLOB.

    Built-in declarative BLOB support is the simplest way to do this, and is still covered in the documentation.

    M.Emmanuel
  • M.Emmanuel
    M.Emmanuel Member Posts: 304
    edited Sep 13, 2016 3:08PM

    From the above link -which is much better than what I was looking for-I am trying to understand what this PL/SQL sentence means:

    sys.owa_util.mime_header( c1.mime_type, FALSE );

    I do not have a MIME_TYPE column in my image table, should there be such column?

    Thanks,

  • fac586
    fac586 Senior Technical Architect Member Posts: 19,934 Red Diamond
    edited Sep 13, 2016 3:18PM
    M.Emmanuel wrote:From the above link -which is much better than what I was looking for-I am trying to understand what this PL/SQL sentence means:sys.owa_util.mime_header( c1.mime_type, FALSE);

    This sets the Content-Type HTTP header to identify the content type of the downloaded resource to the receiving user agent, enabling it to determine how to handle it, for example by displaying it in the browser, opening it in another application, or prompting the user to save it as a local file.

    I do not have a MIME_TYPE column in my image table, should there be such column?

    Yes, this is also covered in the documentation.

    PMONM.Emmanuel
  • M.Emmanuel
    M.Emmanuel Member Posts: 304
    edited Sep 13, 2016 3:21PM

    Also blog post assumes you know how to do this:

    Then, all you need to do is construct a URL in your application which calls this application process, as described in the Application Express Application Builder Users' Guide.  You could manually construct a URL using APEX_UTIL.PREPARE_URL, or specify a link in the declarative attributes of a Report Column.  Just be sure to specify a Request of 'APPLICATION_PROCESS=GETIMAGE' (or whatever your application process name is).  The URL will look something like:

    1

    f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=GETIMAGE:::FILE_ID:<some_valid_id>

    However, I do not fully understand how to construct this URL. I have tried to add a derivative column of type  "Link" and specifying that URL without success. Could you further help on how to define this URL?

    Thanks

  • fac586
    fac586 Senior Technical Architect Member Posts: 19,934 Red Diamond
    edited Sep 13, 2016 3:32PM
    M.Emmanuel wrote:Also blog post assumes you know how to do this... However, I do not fully understand how to construct this URL.

    Maybe these difficulties are an indication that the simpler, fully declarative approach using built-in BLOB support is more appropriate to your current level of expertise.

    PMONMike Kutzorpheus4192
  • M.Emmanuel
    M.Emmanuel Member Posts: 304
    edited Sep 13, 2016 5:13PM

    The following link helps to debug an Application process: How to test an On-Demand Process used for AJAX | Inside Oracle APEX by Patrick Wolf

    It would be helpful to understand why declarative approach should be used instead of Application Process.

    i.e. When using declarative approach is recommended and when an application process might be a better option.

  • Mike Kutz
    Mike Kutz Member Posts: 5,664 Silver Crown
    edited Sep 13, 2016 5:19PM
    M.Emmanuel wrote:The following link helps to debug an Application process: How to test an On-Demand Process used for AJAX | Inside Oracle APEX by Patrick Wolf It would be helpful to understand why declarative approach should be used instead of Application Process. i.e. When using declarative approach is recommended and when an application process might be a better option.

    For K.I.S.S. method of development

    Use the simpler declarative approach

    MK

This discussion has been closed.