| Author |
Problem in uploading big images
|
Shrikant Kulkarni
Ranch Hand
Joined: May 10, 2005
Posts: 42
|
|
Hi, I am using apache's FileUpload to upload images into the data base. I am using oracle 10g data base and image is stored as a BLOB object. I am connecting to the DB using JDBC thin drive. I can upload small images of below 4KB but bigger than that. When I wanted to upload some big images of size 50-100KB, i am getting "Data size is bigger then max size". Any help please.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Search for setMaxSize in this page from the FileUpload documentation: http://jakarta.apache.org/commons/fileupload/using.html Moving to the Other Open Source Projects forum [ May 26, 2006: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Shrikant Kulkarni
Ranch Hand
Joined: May 10, 2005
Posts: 42
|
|
Hi, I have solved this problem by inserting empty_blob() while inserting the BLOB image. Retrieve the row just inserted, and lock it for insertion of the BLOB columns. prapredStatement = connection.prepareStatement("select image from image_upload where log_id = ? and image_name = ? for update"); prapredStatement.setInt(1,logId); prapredStatement.setString(2,imageName); // Execute the SQL statement resultSet = prapredStatement.executeQuery(); // Retrieve Blob streams for Image column, and load the sample file if(resultSet.next()) { // Get the Blob locator and open output stream for the Blob Blob mapBlob = resultSet.getBlob(1); OutputStream blobOutputStream = ((oracle.sql.BLOB)mapBlob).getBinaryOutputStream(); // Open the FileInputStream for insertion into the Blob column // saveTo is File from which where you are getting the image InputStream sampleFileStream = new FileInputStream(saveTo); // Buffer to hold chunks of data to being written to the Blob. byte[] buffer = new byte[10* 1024]; // Read a chunk of data from the sample file input stream, and write the chunk to the Blob column output stream. //Repeat till file has been fully read. int nread = 0; // Number of bytes read while( (nread= sampleFileStream.read(buffer)) != -1 ) // Read //from file blobOutputStream.write(buffer, 0, nread); // Write to Blob // Close both streams sampleFileStream.close(); blobOutputStream.close(); }
|
 |
 |
|
|
subject: Problem in uploading big images
|
|
|