spring-framework / org.springframework.web.reactive.function / BodyInserters / fromMultipartData

fromMultipartData

open static fun <T : Any> fromMultipartData(multipartData: MultiValueMap<String, T>): FormInserter

Return a FormInserter that writes the given MultiValueMap as multipart data. The values in the MultiValueMap can be any Object representing the body of the part, or an org.springframework.http.HttpEntity representing a part with body and headers. The MultiValueMap can be built conveniently using org.springframework.http.client.MultipartBodyBuilder. Also the returned inserter allows for additional entries to be added via FormInserter#with(String, Object).

Note that you can also use the syncBody(Object) method in the request builders of both the WebClient and WebTestClient. In that case the setting of the content type is also not required, just be sure the map contains at least one non-String value or otherwise, without a content-type header as a hint, it would be interpreted as a plain form data request.

Parameters

multipartData - the form data to write to the output message

Return
a BodyInserter that writes multipart data

open static fun <T : Any> fromMultipartData(key: String, value: T): FormInserter

A variant of #fromMultipartData(MultiValueMap) for adding parts as name-value pairs in-line vs building a MultiValueMap and passing it in.

Parameters

key - the part name

value - the part value, an Object or HttpEntity

Return
a FormInserter that can writes the provided multipart data and also allows adding more parts