java.lang.Object | |||
↳ | com.google.api.client.http.AbstractHttpContent | ||
↳ | com.google.api.client.http.MultipartContent | ||
↳ | com.google.api.client.http.MultipartFormDataContent |
Serializes MIME "multipart/form-data" content as specified by RFC 2388: Returning Values from Forms: multipart/form-data
The implementation is a subclass of MultipartContent that sets the media type to"multipart/form-data"
and defaults to
DEFAULT_BOUNDARY
as a boundary string.
The generated content output differs from the superclass one to specifically
meet the "multipart/form-data"
RFC specifications, for example
omitting redundant headers in the content parts (except for nested
"multipart" parts).
Shortcut method addPart(Part, String, String)
is provided in order
to easily set name and file name for the mandatory header
"Content-Disposition"
. This header can be manually set in each
part's headers using the following format (but in this case no consistency
checks are made and the request will most likely fail):
Content-Disposition: form-data; name="user"
Specifications on the "content-disposition" header (RFC 2183):
http://tools.ietf.org/html/rfc2183
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_BOUNDARY |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MultipartFormDataContent()
Creates a new empty
MultipartFormDataContent . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MultipartFormDataContent | addPart(MultipartContent.Part part) | ||||||||||
MultipartFormDataContent |
addPart(MultipartContent.Part part, String dispositionName, String dispositionFilename)
Adds an HTTP multipart part.
| ||||||||||
MultipartFormDataContent |
setBoundary(String boundary)
Sets the boundary string to use (must be not null)
If this is not called, the boundary defaults to
DEFAULT_BOUNDARY | ||||||||||
MultipartFormDataContent | setContentParts(Collection<? extends HttpContent> contentParts) | ||||||||||
final MultipartFormDataContent | setMediaType(HttpMediaType mediaType) | ||||||||||
MultipartFormDataContent | setParts(Collection<MultipartContent.Part> parts) | ||||||||||
void | writeTo(OutputStream out) |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
final static HttpMediaType |
getMultipartFormDataMediaType()
Factory method to create HttpMediaType with media type
"multipart/form-data"
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.api.client.http.MultipartContent
| |||||||||||
From class
com.google.api.client.http.AbstractHttpContent
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
com.google.api.client.http.HttpContent
| |||||||||||
From interface
com.google.api.client.util.StreamingContent
|
Adds an HTTP multipart part.
This is a shortcut method to allow adding the specified name and (optional) filename are added in the"content-disposition"
headers for the content (as per RFC 2183 par. 2). If the header is
already specified in the added part, its value is overridden.part | The Part to add to the content |
---|---|
dispositionName | The name of the part (usually the field name in a web form) |
dispositionFilename | The optional filename of the part (usually for adding a FileContent part) |
Sets the boundary string to use (must be not null)
If this is not called, the boundary defaults toDEFAULT_BOUNDARY
boundary | The new boundary for the content |
---|
NullPointerException | if boundary is null |
---|
IOException |
---|
Factory method to create HttpMediaType with media type
"multipart/form-data"