struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: File Upload - how to speed up?
Date Tue, 26 Feb 2002 15:48:11 GMT

Hi Matt,

>From what I have seen of the sturts upload component the file is saved to
temporary location first.
Therefore you might want to try and minimize that amount of reading and
writing you are doing
with the uploaded file.

Suppose under your webapp you had the following structure

/webapp/uploads/temp    -- Temp versions of the uploaded file go here.  set
with the tempDir action servlet parameter
/webapp/uploads/keep    -- Kept versions of the valid uploaded files go

Now I am assuiming both directories are on the same physical disk so a move
will just change
the pointer to the file and not acually perform an OS copy.

To increase the performance I would cast my FormFile object to a DiskFile
and then move the file to
the keep directory.  This would remove the need to read and write the file
twice as I believe you
are probablly doing.

Of course that is just a thought. :-)

Hope that helps

                    Matt Raible                                                          
                    <matt_raible@y       To:     Struts Users Mailing List <>
          >            cc:                                          
                                         Subject:     File Upload - how to speed up?     
                    11:46 PM                                                             
                    Please respond                                                       
                    to "Struts                                                           
                    Users Mailing                                                        

I'm using the struts-upload sample application to create file upload
in my application.

Using the sample code, a ~50 MB file takes about 13 seconds to upload
I expect to have files that are similar in size, and I wonder how long this
might take over a T1 connection.

Is there anyway to optimize the following code - or is this already

OutputStream bos = new FileOutputStream(filePath);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead =, 0, 8192)) != -1) {
    bos.write(buffer, 0, bytesRead);



Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message