Package com.squareup.okhttp
Class MultipartBuilder
- java.lang.Object
-
- com.squareup.okhttp.MultipartBuilder
-
-
Field Summary
Fields Modifier and Type Field Description static MediaTypeALTERNATIVEThe "multipart/alternative" type is syntactically identical to "multipart/mixed", but the semantics are different.static MediaTypeDIGESTThis type is syntactically identical to "multipart/mixed", but the semantics are different.static MediaTypeFORMThe media-type multipart/form-data follows the rules of all multipart MIME data streams as outlined in RFC 2046.static MediaTypeMIXEDThe "mixed" subtype of "multipart" is intended for use when the body parts are independent and need to be bundled in a particular order.static MediaTypePARALLELThis type is syntactically identical to "multipart/mixed", but the semantics are different.
-
Constructor Summary
Constructors Constructor Description MultipartBuilder()Creates a new multipart builder that uses a random boundary token.MultipartBuilder(String boundary)Creates a new multipart builder that usesboundaryto separate parts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultipartBuilderaddFormDataPart(String name, String value)Add a form data part to the body.MultipartBuilderaddFormDataPart(String name, String filename, RequestBody value)Add a form data part to the body.MultipartBuilderaddPart(Headers headers, RequestBody body)Add a part to the body.MultipartBuilderaddPart(RequestBody body)Add a part to the body.RequestBodybuild()Assemble the specified parts into a request body.MultipartBuildertype(MediaType type)Set the MIME type.
-
-
-
Field Detail
-
MIXED
public static final MediaType MIXED
The "mixed" subtype of "multipart" is intended for use when the body parts are independent and need to be bundled in a particular order. Any "multipart" subtypes that an implementation does not recognize must be treated as being of subtype "mixed".
-
ALTERNATIVE
public static final MediaType ALTERNATIVE
The "multipart/alternative" type is syntactically identical to "multipart/mixed", but the semantics are different. In particular, each of the body parts is an "alternative" version of the same information.
-
DIGEST
public static final MediaType DIGEST
This type is syntactically identical to "multipart/mixed", but the semantics are different. In particular, in a digest, the defaultContent-Typevalue for a body part is changed from "text/plain" to "message/rfc822".
-
PARALLEL
public static final MediaType PARALLEL
This type is syntactically identical to "multipart/mixed", but the semantics are different. In particular, in a parallel entity, the order of body parts is not significant.
-
FORM
public static final MediaType FORM
The media-type multipart/form-data follows the rules of all multipart MIME data streams as outlined in RFC 2046. In forms, there are a series of fields to be supplied by the user who fills out the form. Each field has a name. Within a given form, the names are unique.
-
-
Constructor Detail
-
MultipartBuilder
public MultipartBuilder()
Creates a new multipart builder that uses a random boundary token.
-
MultipartBuilder
public MultipartBuilder(String boundary)
Creates a new multipart builder that usesboundaryto separate parts. Prefer the no-argument constructor to defend against injection attacks.
-
-
Method Detail
-
type
public MultipartBuilder type(MediaType type)
Set the MIME type. Expected values fortypeareMIXED(the default),ALTERNATIVE,DIGEST,PARALLELandFORM.
-
addPart
public MultipartBuilder addPart(RequestBody body)
Add a part to the body.
-
addPart
public MultipartBuilder addPart(Headers headers, RequestBody body)
Add a part to the body.
-
addFormDataPart
public MultipartBuilder addFormDataPart(String name, String value)
Add a form data part to the body.
-
addFormDataPart
public MultipartBuilder addFormDataPart(String name, String filename, RequestBody value)
Add a form data part to the body.
-
build
public RequestBody build()
Assemble the specified parts into a request body.
-
-