Hey Guys,

An update to my last message. I am using the Streaming API in FileUpload.
Here my code snippet:

boolean isMultipart = ServletFileUpload.isMultipartContent(request);

       if(!isMultipart)
           return false;

       try
       {
           ServletFileUpload upload = new ServletFileUpload();
           FileItemIterator iter = upload.getItemIterator(request);

           while (iter.hasNext())
           {
               FileItemStream item = iter.next();
               InputStream stream = item.openStream();
               String name = item.getFieldName();

               if(item.isFormField())
               {
                   formField.put(name, Streams.asString(stream));
               }
               else
               {
                   String originalName =  PathParser.getLastFragment(
item.getName());

                   InputStream data = item.openStream();
                   FileOutputStream out1 = null;
                   String filename =  originalName;

                   try
                   {
                       out1 = new FileOutputStream(filename);
                       int c,i;
                       while ((c = data.read()) != -1)
                       {
                           out1.write(c);
                       }

                        out1.close();
                        data.close();

                       formField.put(name, filename+"?"+originalName);
                   }
                   catch(FileNotFoundException e)
                   {

                   }

As you can see, I am writing the file to the disk. Some how a 6MB file
didn't get uploaded into the Database (I read this file again to put it into
the DB). Small files ~1MB or < 1MB go without a problem. MySQL parameter for
packet size is set to 64MB. I have Tomcat as the servlet container.

Any clues ?

thanks a ton !

Askar

On 6/30/07, Askar Zaidi <[EMAIL PROTECTED]> wrote:

Hey guys,

I could not upload a 6MB file into my DB today. MySQL variable for packet
size is set to 64MB, so thats not a problem. Is there a need to change some
threshold in the commons fileupload API ? How do I do that ?

thanks,
Askar

Reply via email to