Originally posted by Nicole Swan:
I have written the code to upload and download a file from an Oracle database. (After trying various 3rd party beans for this, I broke down and wrote the code myself using the MultipartParser in the com.oreilly.servlet package) One problem though, is that my code only seems to work for text files. I've read that you somehow have to use the file content-type to download different types of files correctly, but I'm not quite sure how or where to use that information.
Also, ultimately, I would like to have the filenames available listed as urls that when clicked would download the appropriate file and prompt the user to choose whether they want to open it from the current location or save it to disk (as is usually done with files in browsers). I have no idea how to do this. If anyone has any ideas, I would be very grateful for your help.
My code:
Thanks in advance!
--Nicole
[ July 26, 2002: Message edited by: Nicole Swan ]
Hi Nicole,
This is how you set the content type and filename of the file to download.
In your
servlet, or whatever:
[CODE]
response.setContentType( "application/pdf" ); //the content type of your downloaded file.
response.setHeader( "Content-Disposition", "filename=MyFileName.pdf" );//Filename set here.
out.print( yourBlobData );
[\CODE]
I think that some versions of IE try to open whatever it can within the browser, so this might
not always cause a "Open/Save" dialog box to pop up.
If you are having trouble with the actual storage/retrieval of the file from the database then check out this post and see if
it helps.
https://coderanch.com/t/354914/Servlets/java/uploading-image-oracle-database-through I hope this gets you on your way.
Scott Duclos