Skip to content

Commit fbd34e6

Browse files
authored
Use snippet for AsyncRequestBody.forBlockingInputStream documentation. (#3610)
1 parent 7595065 commit fbd34e6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/async/AsyncRequestBody.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,26 @@ static AsyncRequestBody fromInputStream(InputStream inputStream, Long contentLen
179179
*
180180
* <p><b>Example Usage</b>
181181
*
182-
* <pre>
183-
* S3Client s3 = ...;
182+
* <p>
183+
* {@snippet :
184+
* S3AsyncClient s3 = S3AsyncClient.create(); // Use one client for your whole application!
184185
*
185-
* InputStream streamToWrite = ...;
186-
* long streamToWriteLength = ...;
186+
* byte[] dataToSend = "Hello".getBytes(StandardCharsets.UTF_8);
187+
* InputStream streamToSend = new ByteArrayInputStream();
188+
* long streamToSendLength = dataToSend.length();
187189
*
188190
* // Start the operation
189191
* BlockingInputStreamAsyncRequestBody body =
190-
* AsyncRequestBody.forBlockingInputStream(streamToWriteLength);
192+
* AsyncRequestBody.forBlockingInputStream(streamToSendLength);
191193
* CompletableFuture<PutObjectResponse> responseFuture =
192194
* s3.putObject(r -> r.bucket("bucketName").key("key"), body);
193195
*
194196
* // Write the input stream to the running operation
195-
* body.writeInputStream(streamToWrite);
197+
* body.writeInputStream(streamToSend);
196198
*
197199
* // Wait for the service to respond.
198200
* PutObjectResponse response = responseFuture.join();
199-
* </pre>
201+
* }
200202
*/
201203
static BlockingInputStreamAsyncRequestBody forBlockingInputStream(Long contentLength) {
202204
return new BlockingInputStreamAsyncRequestBody(contentLength);

0 commit comments

Comments
 (0)