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.SdkFilterInputStream
Input stream representing the content of an
S3Object. In addition to
the methods supplied by the InputStream class,
S3ObjectInputStream supplies 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
ConstructorsConstructorDescriptionS3ObjectInputStream(InputStream in, org.apache.http.client.methods.HttpRequestBase httpRequest) S3ObjectInputStream(InputStream in, org.apache.http.client.methods.HttpRequestBase httpRequest, boolean collectMetrics) -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Can be used to provide abortion logic prior to throwing the AbortedException.intReturns 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.HttpRequestBaseReturns 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, skipMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
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 Details
-
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:
-
getHttpRequest
public org.apache.http.client.methods.HttpRequestBase getHttpRequest()Returns the http request from which this input stream is derived. -
available
Returns 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
- Overrides:
readin classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classcom.amazonaws.internal.SdkFilterInputStream- Throws:
IOException
-
close
Delegate 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
-