ResponseT
- Type of unmarshalled POJO response.ReturnT
- Return type of the apply(Object, AbortableInputStream)
method. Implementations are free to perform
whatever transformations are appropriate.@FunctionalInterface public interface StreamingResponseHandler<ResponseT,ReturnT>
AbortableInputStream
. Callers do not need to worry about calling InputStream.close()
on the content, but if they wish to stop reading data from the stream AbortableInputStream.abort()
may be called
to kill the underlying HTTP connection. This is generally not recommended and should only be done when the cost of reading
the rest of the data exceeds the cost of establishing a new connection. If callers do not call abort and do not read all
of the data in the stream, then the content will be drained by the SDK and the underlying HTTP connection will be returned to
the connection pool (if applicable).Modifier and Type | Method | Description |
---|---|---|
ReturnT |
apply(ResponseT response,
AbortableInputStream inputStream) |
Process the response contents.
|
static <ResponseT> |
toFile(Path path) |
Creates a response handler that writes all response content to the specified file.
|
static <ResponseT> |
toOutputStream(OutputStream outputStream) |
Creates a response handler that writes all response content to the given
OutputStream . |
ReturnT apply(ResponseT response, AbortableInputStream inputStream) throws Exception
response
- Unmarshalled POJO responseinputStream
- Input stream of streamed data.Exception
- if any error occurs during processing of the response. This will be re-thrown by the SDK, possibly
wrapped in an SdkClientException
.static <ResponseT> StreamingResponseHandler<ResponseT,Void> toFile(Path path)
FileAlreadyExistsException
will be thrown.ResponseT
- Type of unmarshalled response POJO. Ignored by handler.path
- Path to file to write to.static <ResponseT> StreamingResponseHandler<ResponseT,Void> toOutputStream(OutputStream outputStream)
OutputStream
. Note that
the OutputStream
is not closed or flushed after writing.ResponseT
- Type of unmarshalled response POJO. Ignored by handler.outputStream
- Output stream to write data to.Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.