Closed
Description
Marc-Christian Schulze opened SPR-16376 and commented
In order to upload a file using the newly introduced method (cf. #20854)
public static <T, P extends Publisher<T>>
MultipartInserter BodyInserters::fromMultipartAsyncData (
String key,
P publisher,
Class<T> elementClass
)
it's necessary to specify the filename and content type along with the publisher.
Right now when streaming asynchronously file content into a multipart request
Publisher<ByteBuffer> filePublisher = ...
WebClient
.create(baseUrl)
.post()
.uri("...")
.body(BodyInserters.fromMultipartAsyncData("file", filePublisher, ByteBuffer.class))
the resulting http request looks like:
--ZAbh_nuM150m0P4R_zq9ywXiM_pJ0IKJq
Content-Disposition: form-data; name="file"
......
--ZAbh_nuM150m0P4R_zq9ywXiM_pJ0IKJq--
As you can see the file name and the content type is not specified. For a correct file upload I would expect the http request to look like:
--ZAbh_nuM150m0P4R_zq9ywXiM_pJ0IKJq
Content-Disposition: form-data; name="file"; filename="myFile.txt"
Content-Type: application/octet-stream
......
--ZAbh_nuM150m0P4R_zq9ywXiM_pJ0IKJq--
Affects: 5.0.2
Issue Links:
- MultipartHttpMessageWriter should not subscribe to Publisher multipart data [SPR-16402] #20948 MultipartHttpMessageWriter should not subscribe to Publisher multipart data ("depends on")
- Support Publishers for multipart data in BodyInserters [SPR-16307] #20854 Support Publishers for multipart data in BodyInserters
- DataBufferUtils.read should not take input stream/channel as parameter [SPR-16403] #20949 DataBufferUtils.read should not take input stream/channel as parameter
- MultipartHttpMessageWriter fails when Publisher is provided as Multipart [SPR-16406] #20952 MultipartHttpMessageWriter fails when Publisher is provided as Multipart