public final class MultipartBodyBuilder
extends java.lang.Object
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("form field", "form value");
Resource image = new ClassPathResource("image.jpg");
builder.part("image", image).header("Baz", "Qux");
MultiValueMap> multipartBody = builder.build();
// use multipartBody with RestTemplate or WebClient
| Modifier and Type | Class and Description |
|---|---|
static interface |
MultipartBodyBuilder.PartBuilder
Builder interface that allows for customization of part headers.
|
static class |
MultipartBodyBuilder.PublisherEntity<T,P extends org.reactivestreams.Publisher<T>>
Specific subtype of
HttpEntity for containing Publishers as body. |
| Constructor and Description |
|---|
MultipartBodyBuilder()
Creates a new, empty instance of the
MultipartBodyBuilder. |
| Modifier and Type | Method and Description |
|---|---|
<T,P extends org.reactivestreams.Publisher<T>> |
asyncPart(java.lang.String name,
P publisher,
java.lang.Class<T> elementClass)
Adds a
Publisher part to this builder, allowing for further header customization with
the returned MultipartBodyBuilder.PartBuilder. |
<T,P extends org.reactivestreams.Publisher<T>> |
asyncPart(java.lang.String name,
P publisher,
ParameterizedTypeReference<T> typeReference)
Adds a
Publisher part to this builder, allowing for further header customization with
the returned MultipartBodyBuilder.PartBuilder. |
MultiValueMap<java.lang.String,HttpEntity<?>> |
build()
Builds the multipart body.
|
MultipartBodyBuilder.PartBuilder |
part(java.lang.String name,
java.lang.Object part)
Adds a part to this builder, allowing for further header customization with the returned
MultipartBodyBuilder.PartBuilder. |
MultipartBodyBuilder.PartBuilder |
part(java.lang.String name,
java.lang.Object part,
MediaType contentType)
Adds a part to this builder, allowing for further header customization with the returned
MultipartBodyBuilder.PartBuilder. |
public MultipartBodyBuilder()
MultipartBodyBuilder.public MultiValueMap<java.lang.String,HttpEntity<?>> build()
public MultipartBodyBuilder.PartBuilder part(java.lang.String name, java.lang.Object part)
MultipartBodyBuilder.PartBuilder.name - the name of the part to add (may not be empty)part - the part to addpublic MultipartBodyBuilder.PartBuilder part(java.lang.String name, java.lang.Object part, @Nullable MediaType contentType)
MultipartBodyBuilder.PartBuilder.name - the name of the part to add (may not be empty)part - the part to addcontentType - the Content-Type header for the part (may be null)public <T,P extends org.reactivestreams.Publisher<T>> MultipartBodyBuilder.PartBuilder asyncPart(java.lang.String name, P publisher, java.lang.Class<T> elementClass)
Publisher part to this builder, allowing for further header customization with
the returned MultipartBodyBuilder.PartBuilder.name - the name of the part to add (may not be empty)publisher - the contents of the part to addelementClass - the class of elements contained in the publisherpublic <T,P extends org.reactivestreams.Publisher<T>> MultipartBodyBuilder.PartBuilder asyncPart(java.lang.String name, P publisher, ParameterizedTypeReference<T> typeReference)
Publisher part to this builder, allowing for further header customization with
the returned MultipartBodyBuilder.PartBuilder.name - the name of the part to add (may not be empty)publisher - the contents of the part to addtypeReference - the type of elements contained in the publisher