Class MultipartContent
- All Implemented Interfaces:
HttpContent
,StreamingContent
By default the media type is "multipart/related; boundary=__END_OF_PART__<random
UUID>__"
, but this may be customized by calling setMediaType(HttpMediaType)
, AbstractHttpContent.getMediaType()
, or setBoundary(String)
.
Implementation is not thread-safe.
- Since:
- 1.14
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Single part of a multi-part request. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
private ArrayList
<MultipartContent.Part> Parts of the HTTP multipart request.private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPart
(MultipartContent.Part part) Adds an HTTP multipart part.final String
Returns the boundary string to use.final Collection
<MultipartContent.Part> getParts()
Returns an unmodifiable view of the parts of the HTTP multipart request.boolean
Default implementation returnstrue
, but subclasses may override.setBoundary
(String boundary) Sets the boundary string to use.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.setMediaType
(HttpMediaType mediaType) Sets the media type to use for the Content-Type header, ornull
if unspecified.setParts
(Collection<MultipartContent.Part> parts) Sets the parts of the HTTP multipart request.void
writeTo
(OutputStream out) Writes the byte content to the given output stream.Methods inherited from class com.google.api.client.http.AbstractHttpContent
computeLength, computeLength, getCharset, getLength, getMediaType, getType
-
Field Details
-
NEWLINE
- See Also:
-
TWO_DASHES
- See Also:
-
parts
Parts of the HTTP multipart request.
-
-
Constructor Details
-
MultipartContent
public MultipartContent() -
MultipartContent
-
-
Method Details
-
writeTo
Description copied from interface:StreamingContent
Writes the byte content to the given output stream.Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the output stream has not been closed, and will fail to work if it has been closed.
- Parameters:
out
- output stream- Throws:
IOException
-
retrySupported
public boolean retrySupported()Description copied from class:AbstractHttpContent
Default implementation returnstrue
, but subclasses may override.- Specified by:
retrySupported
in interfaceHttpContent
- Overrides:
retrySupported
in classAbstractHttpContent
-
setMediaType
Description copied from class:AbstractHttpContent
Sets the media type to use for the Content-Type header, ornull
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.- Overrides:
setMediaType
in classAbstractHttpContent
-
getParts
Returns an unmodifiable view of the parts of the HTTP multipart request. -
addPart
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.
-
setParts
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.
-
setContentParts
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.
-
getBoundary
Returns the boundary string to use. -
setBoundary
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.
-