Package com.amazonaws.services.s3.model
Class S3ObjectInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.amazonaws.internal.SdkFilterInputStream
-
- com.amazonaws.services.s3.model.S3ObjectInputStream
-
- All Implemented Interfaces:
com.amazonaws.internal.MetricAware,com.amazonaws.internal.Releasable,Closeable,AutoCloseable
public class S3ObjectInputStream extends com.amazonaws.internal.SdkFilterInputStreamInput stream representing the content of anS3Object. In addition to the methods supplied by theInputStreamclass,S3ObjectInputStreamsupplies the abort() method, which will terminate an HTTP connection to the S3 object.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description S3ObjectInputStream(InputStream in, org.apache.http.client.methods.HttpRequestBase httpRequest)S3ObjectInputStream(InputStream in, org.apache.http.client.methods.HttpRequestBase httpRequest, boolean collectMetrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Can be used to provide abortion logic prior to throwing the AbortedException.intavailable()Returns super.available() if the value is not zero or else always returns 1.voidclose()Delegate toabort()if there is data remaining in the stream.org.apache.http.client.methods.HttpRequestBasegetHttpRequest()Returns the http request from which this input stream is derived.intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()-
Methods inherited from class com.amazonaws.internal.SdkFilterInputStream
abortIfNeeded, isMetricActivated, mark, markSupported, release, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
S3ObjectInputStream
public S3ObjectInputStream(InputStream in, org.apache.http.client.methods.HttpRequestBase httpRequest)
-
S3ObjectInputStream
public S3ObjectInputStream(InputStream in, org.apache.http.client.methods.HttpRequestBase httpRequest, boolean collectMetrics)
-
-
Method Detail
-
abort
public void abort()
Can be used to provide abortion logic prior to throwing the AbortedException. No-op by default. Aborts the underlying http request without reading any more data and closes the stream.By default Apache
HttpClienttries to reuse http connections by reading to the end of an attached input stream onInputStream.close(). This is efficient from a socket pool management perspective, but for objects with large payloads can incur significant overhead while bytes are read from s3 and discarded. It's up to clients to decide when to take the performance hit implicit in not reusing an http connection in order to not read unnecessary information from S3.- Overrides:
abortin classcom.amazonaws.internal.SdkFilterInputStream- See Also:
EofSensorInputStream
-
getHttpRequest
public org.apache.http.client.methods.HttpRequestBase getHttpRequest()
Returns the http request from which this input stream is derived.
-
available
public int available() throws IOExceptionReturns super.available() if the value is not zero or else always returns 1. This is necessary to get around a GZIPInputStream bug which would mis-behave in some edge cases upon zero returned from available(), causing file truncation.http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7036144
Reference TT: 0034867351
- Overrides:
availablein classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
read
public int read() throws IOException- Overrides:
readin classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
reset
public void reset() throws IOException- Overrides:
resetin classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
close
public void close() throws IOExceptionDelegate toabort()if there is data remaining in the stream. If the stream has been read completely, with no data remaining, safely close the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
-