Thomas Carlton
Thomas Carlton

Reputation: 5968

Apex Oracle : How to get image URL?

I'm running Apex 19.2 on Oracle 18c and I would like to get some images URL to show them in the application. The images are stored in the database as blob (not static images).

For the moment what I did is creating an ORDS Restfull Service that connects to database and load the images. The images are then accessible via an URL that I insert in my pages

<img src="URL to my Restfull service module with the image identifier">

This works well but I find it quite complex and most importantly, it's very slow and doesn't cache the image. Whenever I load the page I have to wait for the image to load (even though it's very small : 50kb)

Does anyone have a solution for this please ? Is there any Apex out of the box solution like for static imaes ?

Thanks, Cheers

enter image description here

Upvotes: 1

Views: 5274

Answers (2)

Thomas Tschernich
Thomas Tschernich

Reputation: 1282

There is no direct method to expose BLOBs to the end user as it would be kind of complicated to secure these files. I can suggest the following two methods:

  1. Use the code just like you did it, but consider putting it in an application process. This way, you can use all your session variables directly. You will then be able to generate a link that does exactly what you want, or call the process from a button or branch. There is a nice tutorial here: https://oracle-base.com/articles/misc/apex-tips-file-download-from-a-button-or-link

  2. Using APEX_UTIL.GET_BLOB_FILE_SRC This function only works out of a apex session and requires you to set up an application page with an item that holds a primary key to your table. I doubt that this is what you want.

Note that APEX_MAIL.GET_IMAGES_URL does not work for your use case - this only works for files in your shared components application files or workspace files.

I actually like your approach, because it may be more lightweight than 1). That the image gets loaded again every time probably does not depend on the method you are using. I guess it is more likely due to the headers you are sending out. Take a look at the cache-control headers on this page: https://developer.mozilla.org/de/docs/Web/HTTP/Headers/Cache-Control

Upvotes: 1

TineO
TineO

Reputation: 1033

Maybe check out APEX_MAIL.GET_IMAGES_URL

It is supposed to do essentially what you need so perhaps you can use it.

Upvotes: 0

Related Questions