Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-13496

FileUpload plugin assumes only one file for a given field name

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • 10.0
    • 7.1.2
    • Old Core
    • Trivial
    • N/A
    • N/A

    Description

      The Apache Commons FileUpload library complies with RFCs in that it allows multiple files to be included with the same form field name in a multipart request. XWiki also handles request parameters with the same name correctly, EXCEPT for files. The FileUpload plugin API includes several methods which implicitly assume only one file has a given form field name:

      • String getFileName(String formfieldName)
      • String getFileItemAsString(String formfieldName)
      • String getFileItem(String formfieldName)
      • byte[] getFileItemData(String formfieldName)

      Internally these methods use
      FileItem getFile(String formfieldName, XWikiContext context) which retrieves the first matching result.

      These API members are incompatible with handling multiple files of the same name. Fortunately the method List<FileItem> getFileItems() allows correct handling. For each of members above their JavaDoc comments should include something along the lines of:

      This method returns the result for the first matching FileItem of the given form field name. If you are dealing with multiple files with the same form field name you should use {@link #getFileItems()}

      Attachments

        Issue Links

          Activity

            People

              akshitdewan Akshit Dewan
              beldaz Bryn Jeffries
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: