title: Tomcat 6.0 Large File Upload (> 2 GB)
body: <p>I am having issues with HTTP file upload with files larger than 2GB. Both server and client are 64 bit so there must be no restriction of 2GB from the system perspective. I did the following:</p>
  
  <ol>
  <li>In Apache 
  LimitRequestBody = 0 (<a href="http://httpd.apache.org/docs/2.0/mod/core.html#LimitRequestBody" rel="nofollow">http://httpd.apache.org/docs/2.0/mod/core.html#LimitRequestBody</a>)</li>
  <li>In Tomcat Connector 
  maxPostSize = 0 (<a href="http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html" rel="nofollow">http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html</a>)</li>
  </ol>
  
  <p>I am using apache commons file upload. I also tried to set max file size using ServerFileUpload setMaxFileSize method.</p>
  
  <p>I am able to upload files less than 2GB (I tried 1.88GB file successfully). Please direct me, what am I missing here?</p>
  
  <p>To be more specific ServletFileUpload.parseRequest method returns 0 FileItems when uploading large files</p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>if (isMultipartForm()) {
  try {
      DiskFileItemFactory factory = new DiskFileItemFactory();
      factory.setSizeThreshold(SIZE_THRESHOLD);//SIZE_THRESHOLD = 4MB
      ServletFileUpload upload = new ServletFileUpload(factory);
          //upload.setFileSizeMax(3000000000L); Tried this too
      upload.setProgressListener(progressListener);
      items = upload.parseRequest(request);
      if(items != null &amp;&amp; items.size() == 0)
      return new CommandResultSet(false, "NoItemsFoundInRequest");
      return new CommandResultSet(true, "" + ( (items!=null) ? items.size() : ""));
  } catch(FileUploadException e) {
      e.printStackTrace();
      System.out.println("Exception in MultipartFormManager. Can not parse request.");    
      return new CommandResultSet(false, e.getMessage());
      }
  }
  </code></pre>