Forum OpenACS Development: Displaying database BLOB image how?

Collapse
Posted by Gaven Eogan on
I have images stored in Oracle DB in BLOB columns.

So what is the correct way to retrieve and display these images on a webpage using OpenACS?

I see the portait-bits code but that is using content repository so no use.

Can the image be read into a variable as normal from DB query and just put on page using @image@ ?

If I have to include some program into an IMG tag like portrait-bits does it, then what are the OpenACS functions I need to use to send the image to browser?

Collapse
Posted by Benjamin Brink on
Per html3ish.. images needed to refer to a url in an IMG tag: https://openacs.org/forums/message-view?message_id=34190

However, html5 (and maybe html4?) and browsers support multiple content types in one page. This[1] page shows an example:

<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

and refers to other reference links.

cheers,
Ben

1. https://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-html

Collapse
Posted by Gaven Eogan on
thanks for your reply.

Interesting. I didn't know that BLOBS were returned as base64 from the database.

Actually I was just trying to find what OpenACS functions could be used to actually return the BLOB data back to the IMG inside the page. I did see that people use small includes inside the image tag and the include program does a "cr_write_content" call but that only works when the image is stored in the conent resository.

I was just trying to find the equivalent function to return a BLOB back to the browser in an include.

But I gave up and went back to using the content repository and its functions after figuring out how to make or use my data as an object (that was why i couldn't use it before)

Collapse
Posted by Benjamin Brink on
I haven't used blobs myself.

I'm not sure if an image blob is in base64. In email, images can be base64.

There's a db command in api called db_blob_get: https://openacs.org/api-doc/proc-view?proc=db_blob_get&source_p=1 It states it's 'PostgreSQL only.' but the source shows code for oracle as well. Maybe it's buggy.

Maybe this thread has something useful: https://openacs.org/forums/message-view?message_id=88888