Skip to content
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

Unable to emulate upload filename browser behaviour with RestTemplate [SPR-15538] #20097

Closed
spring-projects-issues opened this issue May 12, 2017 · 3 comments
Assignees
Labels
in: web type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 12, 2017

Paul opened SPR-15538 and commented

Some browsers (i.e. Chrome and Safari) can send multipart uploads with non-ascii symbols in filename like

Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryNyoLBPoS0jG219lU
…omitted…
------WebKitFormBoundaryNyoLBPoS0jG219lU
Content-Disposition: form-data; name="file"; filename="фывафыва.pdf"
Content-Type: application/pdf


------WebKitFormBoundaryNyoLBPoS0jG219lU--

as you can see filename is UTF-8 string. And MultipartFile handles this correctly!
I need to emulate such behaviour with RestTemplate. Best solution I've found is to use custom FormHttpMessageConverter, but it encodes filename into base64. If I override getFilename() method, removing file encoding to base64 then question marks go to server instead of non-ascii symbols.


Issue Links:

  • #19769 StandardMultipartHttpServletRequest cannot decode multipart Content-Disposition header encoded by FormHttpMessageConverter
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 15, 2017

Rossen Stoyanchev commented

We actually just made this change. It's included in 5.0 RC1 (see commit 75117f). Feel free to give it a try.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 16, 2017

Paul commented

Will it work with Apache http client backend?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 16, 2017

Rossen Stoyanchev commented

Apache Commons FileUpload you mean? If so yes, it will work since we put the charset in the content-type and FileUpload does use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants