commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Askar Zaidi" <askar.za...@gmail.com>
Subject Re: Uploading large file problem
Date Sat, 30 Jun 2007 18:37:25 GMT
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 <askar.zaidi@gmail.com> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message