getting photos out of oracle

Philip Greenspun's Homepage : Philip Greenspun's Homepage Discussion Forums : 6916 : One Thread
Notify me of new responses
This is the problem I am having:
When trying to get photos out of oracle, the statement
#let's pull all photos that this guy is in
set selection [ns_db select $db "
select family_photos.family_photo_id, file_type, caption,
original_width, original_height, client_file_name,
file_extension
from family_photos, family_photo_relative_map
where relative_id=$relative_id
and
family_photos.family_photo_id=family_photo_relative_map.family_photo_id
"]

seems to come back fine, leading me to attempt to display them:

while { [ns_db getrow $db $selection] } {
# there are photos of this guy, let's show them
set_variables_after_query
ns_write "
<center>
<i>$caption</i>
<p>
<img src=\"/attachment/$relative_id/$client_file_name\"
width=$original_width height=$original_height>
</center>"
}

Which is something like general-comments does (or I think it does).


I also tried using ns_ora to pull out the blob into a file, but I
can't find the file the command puts it in (i.e. it's not in the
file name that I give it --
ns_ora blob_get_file $db "select photo from family_photos
where family_photo_id = $photo_id" /family/$photo_id.gif

The statement comes back fine again, but there is no file with
that name anywhere in sight. Upon _much_ looking around, the
file is found to be in /home/nsadmin, which leads me to conclude
that general-comments is configured somehow in the studentXX.ini
file, whereas /family is not. However, I can't find where that
configuration is stored.

Please help. I am not sure whether I am supposed to be using
ns_ora blob_get_file (which would make sense) from the reading
of oracle-driver.html, but the pset itself tells me to use
general-comments as the model for my storing/retrieving photos,
and the code in general-comments (or any other code I could find)
makes no reference to blob_get_file..

Thank you very much.

-- Alex Sverdlov, October 19, 1999

Answers

Retrieving files from oracle

You should be returning the file directly to the connection.

The error was caused because you specified a "relative" web path instead of a "UNIX" full file path. The server tried to save the file in /family, but that directory doesn't exist. You probably intended to save it in /web/studentXX/www/family/

-- Jesse Koontz, October 27, 1999