struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swat...@datachest.com
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
here

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
Scott.




                                                                                         
                                                    
                    Matt Raible                                                          
                                                    
                    <matt_raible@y       To:     Struts Users Mailing List <struts-user@jakarta.apache.org>
                                  
                    ahoo.com>            cc:                                          
                                                       
                                         Subject:     File Upload - how to speed up?     
                                                    
                    02/25/2002                                                           
                                                    
                    11:46 PM                                                             
                                                    
                    Please respond                                                       
                                                    
                    to "Struts                                                           
                                                    
                    Users Mailing                                                        
                                                    
                    List"                                                                
                                                    
                                                                                         
                                                    
                                                                                         
                                                    




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

Using the sample code, a ~50 MB file takes about 13 seconds to upload
locally.
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
optimized?

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

Thanks,

Matt

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   <
mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <
mailto:struts-user-help@jakarta.apache.org>






--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message