request.contentType = 'multipart/form-data'
request.body = multipart {
field 'userid','someuser'
part 'icon', 'user-icon.jpg', 'image/jpeg', imageFile
}
public class MultipartContent
extends java.lang.Object
Multipart request content object used to define the multipart data. An example would be:
request.contentType = 'multipart/form-data'
request.body = multipart {
field 'userid','someuser'
part 'icon', 'user-icon.jpg', 'image/jpeg', imageFile
}
which would define a multipart/form-data request with a field part and a file part with the specified properties.
| Constructor and Description |
|---|
MultipartContent() |
| Modifier and Type | Method and Description |
|---|---|
MultipartContent |
field(java.lang.String fieldName,
java.lang.String value)
Configures a field part with the given field name and value.
|
MultipartContent |
field(java.lang.String fieldName,
java.lang.String contentType,
java.lang.String value)
Configures a field part with the given field name and value (of the specified content type).
|
static MultipartContent |
multipart(Closure closure)
Configures multipart request content using a Groovy closure (delegated to
MultipartContent). |
static MultipartContent |
multipart(java.util.function.Consumer<MultipartContent> config)
Configures multipart request content using a
Consumer which will have an instance of MultipartContent passed into it for
configuring the multipart content data. |
MultipartContent |
part(java.lang.String fieldName,
java.lang.String value)
Configures a field part with the given field name and value.
|
MultipartContent |
part(java.lang.String fieldName,
java.lang.String contentType,
java.lang.String value)
Configures a field part with the given field name and value (of the specified content type).
|
MultipartContent |
part(java.lang.String fieldName,
java.lang.String fileName,
java.lang.String contentType,
java.lang.Object content)
Configures a file part with the specified properties.
|
public static MultipartContent multipart(@DelegatesTo(value=MultipartContent.class) Closure closure)
Configures multipart request content using a Groovy closure (delegated to MultipartContent).
closure - the configuration closureMultipartContentpublic static MultipartContent multipart(java.util.function.Consumer<MultipartContent> config)
Configures multipart request content using a Consumer which will have an instance of MultipartContent passed into it for
configuring the multipart content data.
config - the configuration ConsumerMultipartContentpublic MultipartContent field(java.lang.String fieldName, java.lang.String value)
Configures a field part with the given field name and value.
fieldName - the field namevalue - the valueMultipartContent instancepublic MultipartContent field(java.lang.String fieldName, java.lang.String contentType, java.lang.String value)
Configures a field part with the given field name and value (of the specified content type).
fieldName - the field namecontentType - the value content typevalue - the valueMultipartContent instancepublic MultipartContent part(java.lang.String fieldName, java.lang.String value)
Configures a field part with the given field name and value.
fieldName - the field namevalue - the valueMultipartContent instancepublic MultipartContent part(java.lang.String fieldName, java.lang.String contentType, java.lang.String value)
Configures a field part with the given field name and value (of the specified content type).
fieldName - the field namecontentType - the value content typevalue - the valueMultipartContent instancepublic MultipartContent part(java.lang.String fieldName, java.lang.String fileName, java.lang.String contentType, java.lang.Object content)
Configures a file part with the specified properties. Encoders must be configured on the HttpBuilder to handle the content type
of each configured part.
fieldName - the field namefileName - the file namecontentType - the part content typecontent - the part content (encoders must be configured)MultipartContent instance