Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jan 23, 2014 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 23, 2014

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jan 24, 2014

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

@spring-projects-issues
Copy link
Collaborator Author

Brian Clozel commented

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants