Class BlockingInputStreamAsyncRequestBody
- java.lang.Object
-
- software.amazon.awssdk.core.async.BlockingInputStreamAsyncRequestBody
-
- All Implemented Interfaces:
org.reactivestreams.Publisher<ByteBuffer>,AsyncRequestBody,SdkPublisher<ByteBuffer>
public final class BlockingInputStreamAsyncRequestBody extends Object implements AsyncRequestBody
An implementation ofAsyncRequestBodythat allows performing a blocking write of an input stream to a downstream service.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBlockingInputStreamAsyncRequestBody.Builder-
Nested classes/interfaces inherited from interface software.amazon.awssdk.core.async.AsyncRequestBody
AsyncRequestBody.BodyType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringbody()Each AsyncRequestBody should return a well-formed name that can be used to identify the implementation.static BlockingInputStreamAsyncRequestBody.Builderbuilder()Creates a default builder forBlockingInputStreamAsyncRequestBody.voidcancel()Cancel any running write (and mark the stream as failed).Optional<Long>contentLength()StringcontentType()voidsubscribe(org.reactivestreams.Subscriber<? super ByteBuffer> s)longwriteInputStream(InputStream inputStream)Block the calling thread and write the provided input stream to the downstream service.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.core.async.AsyncRequestBody
split, split, splitCloseable, splitCloseable
-
Methods inherited from interface software.amazon.awssdk.core.async.SdkPublisher
addTrailingData, buffer, doAfterOnCancel, doAfterOnComplete, doAfterOnError, filter, filter, flatMapIterable, limit, map, subscribe
-
-
-
-
Method Detail
-
builder
public static BlockingInputStreamAsyncRequestBody.Builder builder()
Creates a default builder forBlockingInputStreamAsyncRequestBody.
-
contentLength
public Optional<Long> contentLength()
- Specified by:
contentLengthin interfaceAsyncRequestBody- Returns:
- The content length of the data being produced.
-
contentType
public String contentType()
- Specified by:
contentTypein interfaceAsyncRequestBody- Returns:
- The content type of the data being produced.
-
writeInputStream
public long writeInputStream(InputStream inputStream)
Block the calling thread and write the provided input stream to the downstream service.This method will block the calling thread immediately. This means that this request body should usually be passed to the SDK before this method is called.
This method will return the amount of data written when the entire input stream has been written. This will throw an exception if writing the input stream has failed.
You can invoke
cancel()to cancel any blocked write calls to the downstream service (and mark the stream as failed).
-
cancel
public void cancel()
Cancel any running write (and mark the stream as failed).
-
subscribe
public void subscribe(org.reactivestreams.Subscriber<? super ByteBuffer> s)
- Specified by:
subscribein interfaceorg.reactivestreams.Publisher<ByteBuffer>
-
body
public String body()
Description copied from interface:AsyncRequestBodyEach AsyncRequestBody should return a well-formed name that can be used to identify the implementation. The body name should only include alphanumeric characters.- Specified by:
bodyin interfaceAsyncRequestBody- Returns:
- String containing the identifying name of this AsyncRequestBody implementation.
-
-