On Mon, 2005-09-05 at 22:09 -0400, Frank W. Zammetti wrote: > Murray Collingwood wrote: > > Hello again > > > > I'm on the hunt for some sample code that will show me how to use my SQL > > Blob fields > > to store images or documents. > > Here's something on the Wiki to get you started: > > http://wiki.apache.org/struts/StrutsFileDownload > > The sample app posted there includes serving an image from a database.
That said, I'd advise you to consider this again - serving images from the database may slow down your application A LOT (e.g. one of our clients reported a 2-times speedup when they moved their images from database to file system). > > > For a while I entertained the idea of keeping the images and documents in a > > sub- > > directory and simply referencing the file names but then I realised I was > > going to get > > into trouble with synchronising the SQL data with the files on disk. For > > example, what if > > somebody manually deleted one of the files, suddenly I need a bunch of > > conditions to > > handle these inconsistencies. > > Not sure what you mean here... it sounds like you need to store some > info in the database to give some details on what's on the file system, > but I'm not sure what you see as the problem here. What she's worried about is that the image file may be removed/renamed/clobbered outside the application leaving the database record out of sync with the state of the file. It's a common "threat" in such situations and I think you better deal with it instead of pushing the image into the database (as far as I heard MySQL is not transactional yet anyway) > > Regarding the SQL management of blobs, I'm assuming that it is better to > > create a > > separate table for these with two columns, ID (int auto_increment) and > > IMAGE (blob), > > and then to use the ID to reference the image on the other tables where it > > is linked. > > Does this sound right to you? I think this is the recommended practice for blobs if they are accessed much less than the other fields in the record. But it depends on your schema and expected application behaviour as Frank says. Cheers, --Amos --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]