commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew <li...@serff.net>
Subject Very Large File Uploads
Date Fri, 25 Aug 2006 21:47:51 GMT
Hello.  I have seen a few threads about Large file uploads on the 
mailing list, but most people are saying Large means ~10MB.  I'm trying 
to upload files larger than 2 GB using FileUpload and HttpClient.  I 
know some people are going to say "why aren't you using ftp for that?" 
but I have my reasons, so please try to help me with my problems with 
FileUpload.  It seems to work ok for files up to about 1GB, but once I'm 
beyond that, it just hangs forever.  Has anyone had luck doing this with 
FileUpload?  Also, the weird thing is that it seems like the whole file 
gets there, but parseRequest never returns.  And yes, I've let it sit 
for hours...

This is basically what I have in my doPost method of my servlet:
public void doPost(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {
        String tempStore = System.getProperty("java.iot.tmpdir");
        int maxMemorySize = 10000;
        ServletFileUpload sfu = new ServletFileUpload(new 
DiskFileItemFactory(maxMemorySize, new File(tempStore)));
        sfu.setSizeMax(-1);
        List fileItems = sfu.parseRequest(request);
       
        Iterator itr = fileItems.iterator();
       
        while(itr.hasNext()) {
            FileItem fi = (FileItem)itr.next();
            if (!fi.isFormField()) {
                File file = new File(tempStore + fi.getName());
                fi.write(file);
            }
        }
    }

Is there another why I should be doing this? 

I have one other question too.  Is there a way to parse the request with 
out accepting the full multipart content?  I'm using the HttpClient to 
do this upload, and I'm setting a few StringParts in the request so that 
I can authorize the user to upload.  Doing it the way listed above, I 
have to accept the entire request (i.e. they upload the whole file) 
because I get those StringParts.  Should I be putting those parameters 
somewhere other than the PostMethod I'm sending in the executeMethod of 
HttpClient? 

Any help you all can give would be great!  Thanks!
Andrew


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message