Skip to content

Example for AsyncRequestBody.forBlockingOutputStream looks wrong. #6141

Open
@tkhill-AWS

Description

@tkhill-AWS

Describe the issue

The example shown for the javadoc of forBlockingOutputStream is:

   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();

This shows a BlockingInputStreamAsyncRequestBody (notice Input) being returned from the method, but the should be a BlockingOutputStreamAsyncRequestBody.

Links

https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/async/AsyncRequestBody.html#forBlockingOutputStream(java.lang.Long)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationThis is a problem with documentation.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions