Interface ContentStreamProvider

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ContentStreamProvider
    Provides the content stream of a request.

    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.

    • Method Detail

      • fromByteArrayUnsafe

        static ContentStreamProvider fromByteArrayUnsafe​(byte[] bytes)
        Create 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.

      • newStream

        InputStream newStream()
        Returns:
        The content stream.
      • name

        default String name()
        Each ContentStreamProvider should return a well-formed name that can be used to identify the implementation. The stream name should only include alphanumeric characters.
        Returns:
        String containing the identifying name of this ContentStreamProvider implementation.