Class AbstractInputStreamContent
java.lang.Object
com.google.api.client.http.AbstractInputStreamContent
- All Implemented Interfaces:
HttpContent, StreamingContent
- Direct Known Subclasses:
ByteArrayContent, FileContent, InputStreamContent
Serializes HTTP request content from an input stream into an output stream.
The type field is required. Subclasses should implement the HttpContent.getLength(),
getInputStream(), and HttpContent.retrySupported() for their specific type of input stream.
By default, all content is read from the input stream. If instead you want to limit the maximum
amount of content read from the input stream, you may use ByteStreams.limit(InputStream, long).
Implementations don't need to be thread-safe.
- Since:
- 1.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the input stream should be closed at the end ofwriteTo(OutputStream).private StringContent type ornullfor none. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanReturns whether the input stream should be closed at the end ofwriteTo(OutputStream).abstract InputStreamReturn an input stream for the specific implementation type ofAbstractInputStreamContent.getType()Returns the content type ornullfor none.setCloseInputStream(boolean closeInputStream) Sets whether the input stream should be closed at the end ofwriteTo(OutputStream).Sets the content type ornullfor none.voidwriteTo(OutputStream out) Writes the byte content to the given output stream.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HttpContent
getLength, retrySupported
-
Field Details
-
type
Content type ornullfor none. -
closeInputStream
private boolean closeInputStreamWhether the input stream should be closed at the end ofwriteTo(OutputStream). Default istrue.
-
-
Constructor Details
-
AbstractInputStreamContent
- Parameters:
type- Content type ornullfor none- Since:
- 1.5
-
-
Method Details
-
getInputStream
Return an input stream for the specific implementation type ofAbstractInputStreamContent. If the specific implementation will returntrueforHttpContent.retrySupported()this should be a factory function which will create a newInputStreamfrom the source data whenever invoked.- Throws:
IOException- Since:
- 1.7
-
writeTo
Description copied from interface:StreamingContentWrites 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.
- Specified by:
writeToin interfaceHttpContent- Specified by:
writeToin interfaceStreamingContent- Parameters:
out- output stream- Throws:
IOException
-
getType
Description copied from interface:HttpContentReturns the content type ornullfor none.- Specified by:
getTypein interfaceHttpContent
-
getCloseInputStream
public final boolean getCloseInputStream()Returns whether the input stream should be closed at the end ofwriteTo(OutputStream). Default istrue.- Since:
- 1.7
-
setType
Sets the content type ornullfor none. Subclasses should override by calling super.- Since:
- 1.5
-
setCloseInputStream
Sets whether the input stream should be closed at the end ofwriteTo(OutputStream). Default istrue. Subclasses should override by calling super.- Since:
- 1.7
-