Class MultipartContent (1.41.8)

public class MultipartContent extends AbstractHttpContent

Serializes MIME multipart content as specified by RFC 2387: The MIME Multipart/Related Content-type and RFC 2046: Multipurpose Internet Mail Extensions: The Multipart/mixed (primary) subtype.

By default the media type is "multipart/related; boundary=END_OF_PART, but this may be customized by calling #setMediaType(HttpMediaType), #getMediaType(), or #setBoundary(String).

Implementation is not thread-safe.

Inheritance

java.lang.Object > AbstractHttpContent > MultipartContent

Constructors

MultipartContent()

public MultipartContent()

MultipartContent(String boundary)

public MultipartContent(String boundary)
Parameter
NameDescription
boundaryString

Methods

addPart(MultipartContent.Part part)

public MultipartContent addPart(MultipartContent.Part part)

Adds an HTTP multipart part.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
partMultipartContent.Part
Returns
TypeDescription
MultipartContent

getBoundary()

public final String getBoundary()

Returns the boundary string to use.

Returns
TypeDescription
String

getParts()

public final Collection<MultipartContent.Part> getParts()

Returns an unmodifiable view of the parts of the HTTP multipart request.

Returns
TypeDescription
Collection<Part>

retrySupported()

public boolean retrySupported()

Default implementation returns true, but subclasses may override.

Returns
TypeDescription
boolean
Overrides

setBoundary(String boundary)

public MultipartContent setBoundary(String boundary)

Sets the boundary string to use.

Defaults to "END_OF_PART".

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
boundaryString
Returns
TypeDescription
MultipartContent

setContentParts(Collection<? extends HttpContent> contentParts)

public MultipartContent setContentParts(Collection<? extends HttpContent> contentParts)

Sets the HTTP content parts of the HTTP multipart request, where each part is assumed to have no HTTP headers and no encoding.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
contentPartsCollection<? extends com.google.api.client.http.HttpContent>
Returns
TypeDescription
MultipartContent

setMediaType(HttpMediaType mediaType)

public MultipartContent setMediaType(HttpMediaType mediaType)

Sets the media type to use for the Content-Type header, or null if unspecified.

This will also overwrite any previously set parameter of the media type (for example "charset"), and therefore might change other properties as well.

Parameter
NameDescription
mediaTypeHttpMediaType
Returns
TypeDescription
MultipartContent
Overrides

setParts(Collection<MultipartContent.Part> parts)

public MultipartContent setParts(Collection<MultipartContent.Part> parts)

Sets the parts of the HTTP multipart request.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
partsCollection<Part>
Returns
TypeDescription
MultipartContent

writeTo(OutputStream out)

public void writeTo(OutputStream out)
Parameter
NameDescription
outOutputStream
Exceptions
TypeDescription
IOException