jakarta commons file upload and store to mysql

J

Joshua

After a few hours digging around I found a few API's available to
provide file upload functionality. I decided to go with the jakarta
commons file upload classes. I can successfully upload a file,
storing it to disk on the server. I don't want to store a URL to
uploaded files in a table record, and so would rather store the file
itself in a record. I'm using MySql, and so assume I will use the
field type Blob.

Looking at the apache site [1] for customisation information there is
no documentation available. So looking at the available methods of
the FileItem class I can only assume I use the
FileItem.getInputStream() method to pull the contents of the file.

My question is, how do I transfer the contains of the file from the
returned java.io.InputStream into a blob mysql field, if blob is the
way forward of course.

I am using the com.mysql.jdbc.Driver JDBC driver downloaded from
mysql.com.

Any help much appreciated.

[1] http://jakarta.apache.org/commons/fileupload/customizing.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top