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

Multipart/mixed requests using RestTemplate [SPR-5904] #10573

Closed
spring-projects-issues opened this issue Jul 6, 2009 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Graham Zabel opened SPR-5904 and commented

We have a requirement to upload documents (Word, pdf, etc). The Request is expected to be a multipart/mixed MIME type, with the first section containing the Xml defining the document, and the second section containing the actual document.

There currently seems to be very limited support for multipart requests. Could we have support for creation of multipart requests using RestTemplate?

thanks,
Graham


Referenced from: commits def90d1, af4b22e, 0efb9d8

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

This is now implemented. You are able to do the following:

MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
parts.add("name 1", "value 1");
parts.add("name 2", "value 2+1");
parts.add("name 2", "value 2+2");
Resource logo = new ClassPathResource("/org/springframework/http/converter/logo.jpg");
parts.add("logo", logo);
Source xml = new StreamSource(new StringReader("<root><child/></root>"));
parts.add("xml", xml);

template.postForLocation("http://example.com"/multipart", parts);

which results in a multipart form POST, with all entries in the map as separate MIME parts.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0.2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants