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

conceptual error throwing FileUploadException when upload size or file size exeeds limits

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.2
    • None
    • None

    Description

      When any size limits exceed, immediately a FileUploadBase.SizeLimitExceededException or FileUploadBase.FileSizeLimitExceededException is thrown and parsing of the multipart request terminates without providing request parameters for further processing.

      This basically makes it impossible for any web application to handle size limit exceeded cases gracefully.

      My proposal is that request parsing should always complete to deliver the request parameters. Size limit exceeded cases/exceptions might be collected for later retrieval, FileSizeLimitExeededException should be mapped to the FileItem to allow some validation on the FileItem on application level. This would allow to mark upload input fields as erronous if the uploaded file was too big.

      Actually I made a patch for that (see attachment). With this patch, commons-fileupload always completes request parsing in case of size limit exceedings and only after complete parsing will throw an exception if one was detected. Using FileUploadBase.setThrowUploadException(false) no exceptions will be thrown (except more critical ones like invalid stream format).
      After request processing the collected FileUploadExceptions might be retrieved using FileUploadBase.getFileUploadExceptions().

      The patch shows the concept, but further improvement might be necessary.

      Attachments

        1. testMaxSizeLimitAndNormalFormField.patch
          4 kB
          Maurizio Cucchiara
        2. my-changes.patch
          11 kB
          Hanspeter Dünnenberger

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hpdueni Hanspeter Dünnenberger
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: