@FunctionalInterface public interface ContentStreamProvider
Each call to the newStream() method must result in a stream whose position is at the beginning of the content.
Implementations may return a new stream or the same stream for each call. If returning a new stream, the implementation
must ensure to close() and free any resources acquired by the previous stream. The last stream returned by newStream()} will be closed by the SDK.
| Modifier and Type | Method and Description |
|---|---|
static ContentStreamProvider |
fromByteArray(byte[] bytes)
Create
ContentStreamProvider from a byte array. |
static ContentStreamProvider |
fromByteArrayUnsafe(byte[] bytes)
Create
ContentStreamProvider from a byte array without copying the contents of the byte array. |
static ContentStreamProvider |
fromInputStream(InputStream inputStream)
Create a
ContentStreamProvider from an input stream. |
static ContentStreamProvider |
fromInputStreamSupplier(Supplier<InputStream> inputStreamSupplier)
Create
ContentStreamProvider from an input stream supplier. |
static ContentStreamProvider |
fromString(String string,
Charset charset)
Create
ContentStreamProvider from a string, using the provided charset. |
static ContentStreamProvider |
fromUtf8String(String string)
Create
ContentStreamProvider from a string, using the UTF-8 charset. |
InputStream |
newStream() |
static ContentStreamProvider fromByteArray(byte[] bytes)
ContentStreamProvider from a byte array. This will copy the contents of the byte array.static ContentStreamProvider fromByteArrayUnsafe(byte[] bytes)
ContentStreamProvider from a byte array without copying the contents of the byte array.
This introduces concurrency risks, allowing the caller to modify the byte array stored in this
ContentStreamProvider implementation.
As the method name implies, this is unsafe. Use fromByteArray(byte[]) unless you're sure you know
the risks.
static ContentStreamProvider fromString(String string, Charset charset)
ContentStreamProvider from a string, using the provided charset.static ContentStreamProvider fromUtf8String(String string)
ContentStreamProvider from a string, using the UTF-8 charset.static ContentStreamProvider fromInputStream(InputStream inputStream)
ContentStreamProvider from an input stream.
If the provided input stream supports mark/reset, the stream will be marked with a 128Kb read limit and reset
each time newStream() is invoked. If the provided input stream does not support mark/reset,
newStream() will return the provided stream once, but fail subsequent calls. To create new streams when
needed instead of using mark/reset, see fromInputStreamSupplier(Supplier).
static ContentStreamProvider fromInputStreamSupplier(Supplier<InputStream> inputStreamSupplier)
ContentStreamProvider from an input stream supplier. Each time a new stream is retrieved from
this content stream provider, the last one returned will be closed.InputStream newStream()
Copyright © 2026. All rights reserved.