View Single Post
  #5 (permalink)  
Old November 1st, 2004, 05:34 AM
angrycat angrycat is offline
Friend of Wrox
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts


You could have a look at this thread on a similar subject, has some code snippets I posted that show in brief how I uploaded images to my database:

I see at one point you have data in a BinaryInputStream, so Ill start there:

// fileBytes was the byteArray I read data into from the POST method
bin = new ByteArrayInputStream( fileBytes, 2, offset-2 );

// necessary to convert ByteArrayInputStream to InputStream
InputStream is = bin;

// setBinaryStream is the only way I have found to put a Blob
// into the database, and it will only take a standard InputStream.

pstmt.setBinaryStream( 5, is, (int)(len));

You should be able to run your code to check the size of the image before converting the data type to an InputStream for uploading to the database.

I have done something similar which watermarked an image with a URL, saved it to the database, then resized it to a thumbnail and saved this also.

Reply With Quote