Skip to content

@RequestPart(...) MultipartFile[] does not work (List<MultipartFile works) [SPR-11353] #15978

Closed

Description

@spring-projects-issues

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:

Referenced from: commits cc0a845

0 votes, 5 watchers

Activity

  1. spring-projects-issues commented on Jan 24, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Brian, this looks related to #15220 - may be easy enough to address for 4.0.1 still, along the same lines as your pull request back then?

    Juergen

  2. spring-projects-issues commented on Jan 24, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    Sure!

  3. added
    type: enhancement
    in: web
    on Jan 11, 2019
  4. added this to the 4.0.1 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions