Forum OpenACS Q&A: blob confusion

Collapse
Posted by Jacques Williams on

I am having some trouble figuring out how to retrieve a jpeg file stored using Don Baccus' lob hack.

The setup:

  • RedHat 6.2
  • PostgreSQL 7.0.1
  • OpenACS 3.2.4

Apparently, I am storing jpeg files in the database without any difficulty. Here is how I am trying to retrieve them:

set db [ns_db gethandle]
set lob [database_to_tcl_string $db "select lob from
public_space_images where
public_space_image_id=$public_space_image_id"]
set image [ns_pg blob_write $db $lob]
set image_string (img src=$image)
# the img tag has angle brackets in the real thing -- Netscape doesn't
# seem to handle preformatted text very well
ns_return 200 text/html $image_string
This doesn't completely make sense to me, because the src tag should be a file, but I can't think what else to do. In any case, the log shows no errors, but this returns an empty variable.

Thanks, as always, for your help.

Collapse
2: Response to blob confusion (response to 1)
Posted by Dan Wickstrom on
blob_write writes the image directly to the connection.  You need something like:

ReturnHeaders image/jpg

ns_pg blob_write $db $lob