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 anS3Object
. In addition to the methods supplied by theInputStream
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
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 void
abort()
Can be used to provide abortion logic prior to throwing the AbortedException.int
available()
Returns super.available() if the value is not zero or else always returns 1.void
close()
Delegate toabort()
if there is data remaining in the stream.org.apache.http.client.methods.HttpRequestBase
getHttpRequest()
Returns the http request from which this input stream is derived.int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
void
reset()
-
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
HttpClient
tries 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:
abort
in 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 IOException
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:
available
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
read
public int read() throws IOException
- Overrides:
read
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
close
public void close() throws IOException
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classcom.amazonaws.internal.SdkFilterInputStream
- Throws:
IOException
-
-