-
Notifications
You must be signed in to change notification settings - Fork 38.1k
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
BodyInserters.fromMultipartData swallows content type in certain cases #26410
Comments
Hi @poutsma , public Mono<ResponseEntity<SomeEntityId>> upload(
@RequestBody Mono<MultiValueMap<String, Part>> parts) {
return someServiceClient.upload(parts.map(m -> (FilePart) m.get("foo").get(0)); //here I take the foo part
}
public Mono<ResponseEntity<SomeEntityId>> upload(
Mono<MultiValueMap<String, Part>> partsMono) {
return multipartFile.flatMap(file -> {
MultipartBodyBuilder multipartBodyBuilder = new MultipartBodyBuilder();
multipartBodyBuilder.part("bar", file); //here I rename it to bar
return webClient.post()
.uri("uri")
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA.toString())
.body(BodyInserters.fromMultipartData(multipartBodyBuilder.build()))
});
} I came across this issue when upgrading my spring version : when I do this, in the outgoing request, the part that I wanted to rename "bar" is still named "foo". It worked in spring 5.2.8 (it renamed the part) but in 5.3.6 the file is not renamed anymore. Do you have any advice ? |
@AbdelHedhili Please file a separate issue for this problem. Feel free to ping me on said issue. |
Affects: 5.3.3
My use case is that I need to proxy some multipart form to another service:
Problem here is that
BodyInserters.fromMultipartData
swallows content type fromPart.headers()
.As a workaround I convert
MultiValueMap
before passing it toBodyInserters.fromMultipartData
:I'm not sure how it's actually supposed to work, but perhaps here, apart from
context()
, is it worth it to copyheaders()
as well?The text was updated successfully, but these errors were encountered: