Friday, 20 December 2013

How to Download BLOB Content as a File Using Oracle Application Express


In a previous article, you learned how to create a simple Oracle Application Express application to store the content of any file into a BLOB column in the database.
In this article, you will learn how to include in a report a file download link to the content stored in a BLOB column. If the BLOB contains an image, you’ll learn how to display it in the report as well. Application Express makes this functionality extremely simple to implement.

Oracle Application Express includes BLOB support for both classic and interactive reports. If you use a wizard to create a report and include a column of type BLOB, basic support will be included.
Let’s do it. Using the wizard, create an interactive report based on the table X_FILES (the same table we created earlier). A basic download link will be automatically created.

The key to manipulating the download link of a BLOB column is the column’s format mask. In the same way you specify a format mask for a date or number you can format a download link. However, the DOWNLOAD format mask requires you to specify at least three parameters, for example:
DOWNLOAD:X_FILES:BLOB_CONTENT:ID
This is the default format that gets created by the wizard. Additional format options may be added to make the download capability more user friendly.
Modify the format of the BLOB_CONTENT column to be:
DOWNLOAD:X_FILES:BLOB_CONTENT:ID::MIME_TYPE:FILENAME:LAST_UPDATED:CHARACTER_SET:attachment:Download File

Clicking on the link “BLOB Download Format Mask” displays a popup to assist you in entering all the parameters necessary for the DOWNLOAD format:

If the BLOB contains an image, you can display it in the report as well. To do this, you use the Format Mask of “IMAGE” instead of “DOWNLOAD”:

Regardless of the MIME type, the report will always attempt to display the BLOB. If the BLOB cannot be rendered, a broken image will be displayed:

For more information about BLOB support in Oracle Application Express forms and reports refer to the

No comments:

Post a Comment