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.
|
Constructor and Description |
---|
MultipartBodyBuilder()
Creates a new, empty instance of the
MultipartBodyBuilder . |
Modifier and Type | Method and Description |
---|---|
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
)