[ 
https://issues.apache.org/jira/browse/FILEUPLOAD-239?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Neidhart resolved FILEUPLOAD-239.
----------------------------------------
    Resolution: Invalid

In r1638215 I have added a unit test based on the example in 
http://www.ietf.org/rfc/rfc1867.txt section 6, Examples, which shows that 
fileupload already supports this.

I close this ticket as invalid, as the referenced rfc clearly states that any 
part of a multipart/form-data is expected to have a content-disposition set to 
"form-data" (section 7). If multiple files are uploaded, a multipart/mixed part 
can be used to group them together, in which case other dispositions can be 
used, as outlined in the example. 

> Content-Disposition: attachment; does not work properly
> -------------------------------------------------------
>
>                 Key: FILEUPLOAD-239
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-239
>             Project: Commons FileUpload
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 1.3
>            Reporter: Christoph Hartmann
>
> If I submit data to a server as:
> {code:none}
> ----------------------------336962109586438949853174
> Content-Disposition: form-data; name="file"; filename="basketball.png"
> Content-Type: image/png
> content goes here
> ----------------------------336962109586438949853174--
> {code}
> the upload works as expected and FileUploadBase.findNextItem() recognize the 
> image as a file.
> But if I upload the file as 
> {code:none}
> --729ci2jje8exo4cr3u1h8kmis86ksupq
> Content-Type: image/png
> Content-Disposition: attachment; name="file"; filename="basketball.png
> content goes here
> --729ci2jje8exo4cr3u1h8kmis86ksupq
> {code}
>  FileUploadBase.findNextItem() does not recognize the image as a file. As 
> specified in http://www.ietf.org/rfc/rfc1867.txt this should according to the 
> specification work.
> The problem is located in FileUploadBase.findNextItem() where we call
> {code:none}
> // We're parsing the outer multipart
> String fieldName = getFieldName(headers);
> {code}
> If I am right we should change the the following function:
> {code:none}
>     /**
>      * Returns the field name, which is given by the content-disposition
>      * header.
>      * @param pContentDisposition The content-dispositions header value.
>      * @return The field jake
>      */
>     private String getFieldName(String pContentDisposition) {
>         String fieldName = null;
>         if (pContentDisposition != null
>                 && pContentDisposition.toLowerCase().startsWith(FORM_DATA)) {
>             ParameterParser parser = new ParameterParser();
>             parser.setLowerCaseNames(true);
>             // Parameter parser can handle null input
>             Map params = parser.parse(pContentDisposition, ';');
>             fieldName = (String) params.get("name");
>             if (fieldName != null) {
>                 fieldName = fieldName.trim();
>             }
>         }
>         return fieldName;
>     }
> {code}
> Instead of if 
> {code:none}
> (pContentDisposition != null && 
> pContentDisposition.toLowerCase().startsWith(FORM_DATA))
> {code} 
> we should use
> {code:none}
> (pContentDisposition != null && 
> (pContentDisposition.toLowerCase().startsWith(FORM_DATA)) || 
> pContentDisposition.toLowerCase().startsWith(ATTACHMENT)))
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to