public interface AsyncRequestProvider extends org.reactivestreams.Publisher<ByteBuffer>
Publisher
of data (specifically ByteBuffer
chunks) and the HTTP client is the Subscriber
of the data (i.e. to write that data on the wire).
Publisher.subscribe(Subscriber)
should be implemented to tie this publisher to a subscriber. Ideally each call to subscribe
should reproduce the content (i.e if you are reading from a file each subscribe call should produce a Subscription
that reads the file fully). This allows for automatic retries to be performed in the SDK. If
the content is not reproducible, an exception may be thrown from any subsequent Publisher.subscribe(Subscriber)
calls.
It is important to only send the number of chunks that the subscriber requests to avoid out of memory situations.
The subscriber does it's own buffering so it's usually not needed to buffer in the publisher. Additional permits
for chunks will be notified via the Subscription.request(long)
method.
FileAsyncRequestProvider
Modifier and Type | Method and Description |
---|---|
long |
contentLength() |
static AsyncRequestProvider |
fromFile(Path path)
Creates an
AsyncRequestProvider that produces data from the contents of a file. |
static AsyncRequestProvider |
fromString(String string)
Creates an
AsyncRequestProvider that uses a single string as data with UTF_8 encoding. |
static AsyncRequestProvider |
fromString(String string,
Charset cs)
Creates an
AsyncRequestProvider that uses a single string as data. |
long contentLength()
static AsyncRequestProvider fromFile(Path path)
AsyncRequestProvider
that produces data from the contents of a file. See
FileAsyncRequestProvider.builder()
to create a customized provider implementation.path
- Path to file to read from.AsyncRequestProvider
that reads data from the specified file.FileAsyncRequestProvider
static AsyncRequestProvider fromString(String string, Charset cs)
AsyncRequestProvider
that uses a single string as data.string
- The string to provide.cs
- The Charset
to use.AsyncRequestProvider
that uses the specified string.SingleByteArrayAsyncRequestProvider
static AsyncRequestProvider fromString(String string)
AsyncRequestProvider
that uses a single string as data with UTF_8 encoding.string
- The string to provider.AsyncRequestProvider
that uses the specified string.fromString(String, Charset)
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.