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

FileUpload plugin assumes only one file for a given field name

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 7.1.2
    • Fix Version/s: 10.0
    • Component/s: Old Core
    • Labels:
    • Difficulty:
      Trivial
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response: