Each AsyncRequestBody should return a well-formed name that can be used to identify the implementation. The body name should only include alphanumeric characters.
Creates an
AsyncRequestBody
the produces data from the input ByteBuffer publisher. The data is delivered when the publisher publishes the data.
publisher
- Publisher of source data
AsyncRequestBody
that produces data send by the publisher
file
- The file to read from.
AsyncRequestBody
that reads data from the specified file.
configuration
- configuration for how the SDK should read the file
AsyncRequestBody
that reads data from the specified file.
configuration
- configuration for how the SDK should read the file
AsyncRequestBody
that reads data from the specified file.
Creates an
AsyncRequestBody
from a byte array. This will copy the contents of the byte array to prevent modifications to the provided byte array from being reflected in the
AsyncRequestBody
.
bytes
- The bytes to send to the service.
Creates an
AsyncRequestBody
from a byte array
withoutcopying the contents of the byte array. This introduces concurrency risks, allowing: (1) the caller to modify the byte array stored in this
AsyncRequestBody
implementation AND (2) any users of
fromBytesUnsafe(byte[])
to modify the byte array passed into this
AsyncRequestBody
implementation.
As the method name implies, this is unsafe. Use fromBytes(byte[])
unless you're sure you know the risks.
bytes
- The bytes to send to the service.
byteBuffer
- ByteBuffer to send to the service.
byteBuffer
- ByteBuffer to send to the service.
byteBuffer
- ByteBuffer to send to the service.
byteBuffer
- ByteBuffer to send to the service.
byteBuffers
- ByteBuffer array to send to the service.
byteBuffers
- ByteBuffer array to send to the service.
byteBuffers
- ByteBuffer array to send to the service.
byteBuffers
- ByteBuffer array to send to the service.
inputStream
- The input stream containing the data to be sent
contentLength
- The content length. If a content length smaller than the actual size of the object is set, the client will truncate the stream to the specified content length and only send exactly the number of bytes equal to the content length.
executor
- The executor
Creates a
BlockingInputStreamAsyncRequestBody
to use for writing an input stream to the downstream service.
By default, it will time out if streaming hasn't started within 10 seconds, and use application/octet-stream as content type. You can configure it via BlockingInputStreamAsyncRequestBody.builder()
Example Usage
S3AsyncClient s3 = S3AsyncClient.create(); // Use one client for your whole application!
byte[] dataToSend = "Hello".getBytes(StandardCharsets.UTF_8);
InputStream streamToSend = new ByteArrayInputStream(dataToSend);
long streamToSendLength = dataToSend.length;
// Start the operation
BlockingInputStreamAsyncRequestBody body =
AsyncRequestBody.forBlockingInputStream(streamToSendLength);
CompletableFuture<PutObjectResponse> responseFuture =
s3.putObject(r -> r.bucket("bucketName").key("key"), body);
// Write the input stream to the running operation
body.writeInputStream(streamToSend);
// Wait for the service to respond.
PutObjectResponse response = responseFuture.join();
contentLength
- The content length. If a content length smaller than the actual size of the object is set, the client will truncate the stream to the specified content length and only send exactly the number of bytes equal to the content length.
BlockingInputStreamAsyncRequestBody
.
Creates a
BlockingOutputStreamAsyncRequestBody
to use for writing to the downstream service as if it's an output stream. Retries are not supported for this request body.
The caller is responsible for calling OutputStream.close()
on the BlockingOutputStreamAsyncRequestBody.outputStream()
when writing is complete.
By default, it will time out if streaming hasn't started within 10 seconds, and you can configure the timeout via BlockingOutputStreamAsyncRequestBody.builder()
Example Usage
S3AsyncClient s3 = S3AsyncClient.create(); // Use one client for your whole application!
byte[] dataToSend = "Hello".getBytes(StandardCharsets.UTF_8);
long lengthOfDataToSend = dataToSend.length();
// Start the operation
BlockingInputStreamAsyncRequestBody body =
AsyncRequestBody.forBlockingOutputStream(lengthOfDataToSend);
CompletableFuture<PutObjectResponse> responseFuture =
s3.putObject(r -> r.bucket("bucketName").key("key"), body);
// Write the input stream to the running operation
try (CancellableOutputStream outputStream = body.outputStream()) {
outputStream.write(dataToSend);
}
// Wait for the service to respond.
PutObjectResponse response = responseFuture.join();
contentLength
- The content length. If a content length smaller than the actual size of the object is set, the client will truncate the stream to the specified content length and only send exactly the number of bytes equal to the content length.
BlockingOutputStreamAsyncRequestBody
.
Converts this
AsyncRequestBody
to a publisher of
AsyncRequestBody
s, each of which publishes a specific portion of the original data, based on the provided
AsyncRequestBodySplitConfiguration
. The default chunk size is 2MB and the default buffer size is 8MB.
By default, if content length of this AsyncRequestBody
is present, each divided AsyncRequestBody
is delivered to the subscriber right after it's initialized. On the other hand, if content length is null, it is sent after the entire content for that chunk is buffered. In this case, the configured maxMemoryUsageInBytes
must be larger than or equal to chunkSizeInBytes
. Note that this behavior may be different if a specific implementation of this interface overrides this method.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4