Uploaded image for project: 'Commons FileUpload'
  1. Commons FileUpload
  2. FILEUPLOAD-200

During ServletFileUpload.parseRequest(factory) the servlet appears to read the data from the users file.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 1.2.2
    • None
    • None
    • CentOS 5/Tomcat 7/JDK 1.7 (No Struts, etc...)

    Description

      I have a very basic FileUpload Servlet I am working on. Using the following code:
      FileUploadListener listener = new FileUploadListener();
      context.log("DEBUG: Created listener");
      FileItemFactory factory = new DiskFileItemFactory();
      context.log("DEBUG: Created Disk Factory");
      ServletFileUpload uploader = new ServletFileUpload(factory);
      context.log("DEBUG: Created ServletFileUpload(factory)");

      request.getSession().setAttribute("ProgressListener",listener);
      context.log("DEBUG: Listner added to Session");

      List<FileItem> items = uploader.parseRequest(request);
      // GETS HERE ONLY AFTER WAITING FOR THE WHOLE FILE
      context.log("DEBUG: parsedRequest for FileItems");
      for (FileItem element : items) {
      if (!element.isFormField()) {
      context.log("DEBUG:" + element.getName());
      File fqfn = new File(f+"/"+element.getName());
      <snip>

      I try to upload a file (1G) the servlet appears to "upload" the file during the parseRequest() call. This appears to be not valid, as the List<FileItem> is pointless when trying to use the Listener to tell how much has been uploaded. The user has already had to wait for the parseRequest() to complete, and by then the listener says 0 bytes of Unknown Size.

      The file will write in the List<FileItem> loop. The reason I think this is a bug, is that I was expecting the parseRequest() to not "upload" the file but rather to return a list of the formfields as FileItems, and then during the FileItem loop and the subsequent write() call, the data would actually be written and therefore the Listener would function. Perhaps, I do not understand what the API is saying, or am missing some critical point. However, all the examples I see online from the Fileupload Site on ASF have the exact same behavior.

      Thanks for your time and work.

      Thomas

      Attachments

        Activity

          People

            Unassigned Unassigned
            polliard Thomas Polliard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: