Class MultiPartOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class MultiPartOutputStream
    extends OutputStream
    An OutputStream which packages data written to it into discrete StreamParts which can be obtained in a separate thread via iteration and uploaded to S3.

    A single MultiPartOutputStream is allocated a range of part numbers it can assign to the StreamParts it produces, which is determined at construction.

    It's essential to call close() when finished so that it can create the final StreamPart and consumers can finish.

    Writing to the stream may lead to trying to place a completed part on a queue, which will block if the queue is full and may lead to an InterruptedException.

    • Method Detail

      • write

        public void write​(byte[] b,
                          int off,
                          int len)
        Overrides:
        write in class OutputStream
      • close

        public void close()
        Packages any remaining data into a StreamPart and signals to the StreamTransferManager that there are no more parts afterwards. You cannot write to the stream after it has been closed.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Overrides:
        close in class OutputStream