aspose file tools*
The moose likes JDBC and the fly likes  Downloading file from Oracle DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark " Downloading file from Oracle DB" Watch " Downloading file from Oracle DB" New topic
Author

Downloading file from Oracle DB

Nicole Swan
Greenhorn

Joined: May 24, 2002
Posts: 6
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 ]
Scott Duclos
Greenhorn

Joined: Jul 12, 2002
Posts: 3
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.
http://www.coderanch.com/t/354914/Servlets/java/uploading-image-oracle-database-through
I hope this gets you on your way.
Scott Duclos
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Downloading file from Oracle DB
 
Similar Threads
Access is Denied
JDBC AND STORING IMAGES/AUDIO/VIEDEO FILES
Problem inserting Blob into Oracle DB
store and retreive the image from oracle
Uploading and Retrieving images using Java/JDBC