Details
-
Improvement
-
Resolution: Fixed
-
Minor
-
7.1.2
-
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
- links to