Display images stored as database BLOBs in a load balanced environment

84 views
Skip to first unread message

Simon Goldschmidt

unread,
May 18, 2016, 6:17:34 AM5/18/16
to Lucee
We display images that we store as BLOBs in a database using a tag like <cfimage action="writetobrowser" source="#dbimage.blobdata#">. This creates a link like this <img src="/lucee/graph.cfm?img=69F1D7AD-953B-4707-BE1A5D6F9F187A6C.png&type=png" /> which works fine in a single server environment, but in a load balanced server it may end up being requested of a server that knows nothing about it.

Any suggestions how we might achieve the same thing in a load balanced environment?

Thanks,
Simon

Jedihomer Townend

unread,
May 18, 2016, 6:22:16 AM5/18/16
to lu...@googlegroups.com
Hi, 


You could grab the blob from the DB, convert it to base64 then use the <img src="data:image/jpeg;base64,{base64here}> style to show the image?

--
Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/40c3b96c-1276-4192-af1f-570c2d3892e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Drew

unread,
May 18, 2016, 6:24:16 AM5/18/16
to lucee
I have no particular reason why not to use a DB for images but it doesn’t sound good, and you just hit a reason why.. 

Are these images something that you could view anyway? I.e. essentially public? Why not create a script that gets that image for you? and just link it as a standard image:
(pseudo non-tested code)
viewimage.cfm?imgid=xyz

<cfcontent type=“image/png”>
<cfoutput>#dbimage.blobdata#</cfoutput>

and then in your main file:
<img src="viewimage.cfm?imgid=xyz" /> 


Then the script would work in a load balanced env. 

MD


Simon Goldschmidt

unread,
May 18, 2016, 6:35:12 PM5/18/16
to Lucee
Thanks for the suggestions.

I like the idea of hitting the web/database server once and spitting out a page with images embedded, but browsers seem to implement the <img src="data:image/jpeg;base64,{base64here}> option inconsistently, so we went with Mark's option.

The code that works for us in the viewimage.cfm page is <cfcontent reset="yes" variable="#dbimage.blobdata#" type="image/png">

Simon
Reply all
Reply to author
Forward
0 new messages