org.reactivestreams.Publisher<ByteBuffer>
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 | Description |
---|---|---|
long |
contentLength() |
|
static AsyncRequestProvider |
fromFile(Path path) |
Creates an
AsyncRequestProvider that produces data from the contents of a file. |
long contentLength()
static AsyncRequestProvider fromFile(Path path)
AsyncRequestProvider
that produces data from the contents of a file.path
- Path to file to read from.AsyncRequestProvider
that reads data from the specified file.Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.