Forum OpenACS Q&A: BLOB in HTML

Request notifications

Posted by Samer Abukhait on
is there a way to view images stored in the databse directly in ADPs??
rather than extraxting them to a file system first.
2: Response to BLOB in HTML (response to 1)
Posted by Tilmann Singer on
Try this in a .tcl file (without an .adp file):

ReturnHeaders $mime_type

db_write_blob write_content {
  select content from cr_revisions where revision_id=:revision_id

3: Response to BLOB in HTML (response to 1)
Posted by Samer Abukhait on
Thank you, that worked..

But what if i want to display more than one image on the same page? and use HTML manage the display?

4: Response to BLOB in HTML (response to 1)
Posted by Don Baccus on
Check out /packages/file-storage/www/download/index.vuh.  It will download an arbitrary content revision if you're using the content repository to store your blobs (which I recommend if you're using OpenACS 4).

Then in your ADP page just use an IMG tag with the URL pointing to the download/index.vuh script and the revision id as the argument (check the source).

If you're not using OpenACS 4 or not storing images in the content repository then you can still use this as a guide.  The general idea is to take the code snippet mentioned in the previous post, put it in a download file, define a parameter that tells it which database row contains the image, then call it from an IMG tag.