February 21st, 2002, 05:43 AM
I want to extract files from my database so my administrator can view these files. The files can be either images or .doc's. Does anybody have any ideas how i could do this.
February 21st, 2002, 06:20 AM
You can store them as blobs (binary large objects) or clobs(character large objects), if your database will support them. Though you can't treat them the same as you would other data that you insert/retrieve from a db, you instead have to get a reference to them from the db and use a (input/ouptut)stream to write/read from them.
Once you've got them you can stream them to the client on the servletOutputStream, and set the contentType to the relevant type (must be done before opening the stream if I remember rightly though).
Is this the kind of answer you were looking for?
This isn't pretty, and if you can avoid it I would. If it is secure you could always use the db to store the file name and path, then just redirect a browser to the specified file. Clobs and Blobs are as far as I'm aware not even stored in the main db, they are more like pointers to files that external to the db