Description
Benjamin M opened SPR-11353 and commented
I just discovered a minor issue, that was really nasty to discover.
@RequestMapping
(...)
void upload1(@RequestPart
("files[]") MultipartFile[] files) { ... }
This throws some HttpMediaTypeNotSupportedException, because it takes all data that comes within files[] and tries to convert it via HttpMessageConverters.
When using List instead of MultipartFile[] it works as expected.
My Request looks like that:
Accept:*/*
Content-Length:4103
Content-Type:multipart/form-data; boundary=----WebKitFormBoundarynSUtw4ABfNjtPL29
------WebKitFormBoundarynSUtw4ABfNjtPL29
Content-Disposition: form-data; name="files[]"; filename="id_rsa.pub"
Content-Type: application/octet-stream
------WebKitFormBoundarynSUtw4ABfNjtPL29
Content-Disposition: form-data; name="files[]"; filename="test.csv"
Content-Type: text/csv
------WebKitFormBoundarynSUtw4ABfNjtPL29--
And afterwards I get an HTTP 415 which says:
Sent Content-Type "application/octet-stream" is not supported. Supported Content-Types are: "application/json;charset=UTF-8", "application/*+json;charset=UTF-8", "text/vcard", "application/octet-stream", "text/plain;charset=ISO-8859-1", "application/xml", "text/xml", "application/x-www-form-urlencoded", "application/*+xml", "multipart/form-data", "*/*"
Affects: 4.0 GA
Issue Links:
- Spring's support for javax.servlet.http.Part vs. MultipartFile incomplete, inconsistent [SPR-10591] #15220 Spring's support for javax.servlet.http.Part vs. MultipartFile incomplete, inconsistent
- Part list/array gets resolved to all parts in current request [SPR-13893] #18467 Part list/array gets resolved to all parts in current request
Referenced from: commits cc0a845
0 votes, 5 watchers