Package alex.mojaki.s3upload
Class MultiPartOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- alex.mojaki.s3upload.MultiPartOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class MultiPartOutputStream extends OutputStream
AnOutputStreamwhich packages data written to it into discreteStreamParts which can be obtained in a separate thread via iteration and uploaded to S3.A single
MultiPartOutputStreamis allocated a range of part numbers it can assign to theStreamParts it produces, which is determined at construction.It's essential to call
close()when finished so that it can create the finalStreamPartand 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.
-
-
Field Summary
Fields Modifier and Type Field Description static intS3_MIN_PART_SIZE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Packages any remaining data into aStreamPartand signals to theStreamTransferManagerthat there are no more parts afterwards.StringtoString()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
-
-
-
Field Detail
-
S3_MIN_PART_SIZE
public static final int S3_MIN_PART_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
write
public void write(int b)
- Specified by:
writein classOutputStream
-
write
public void write(byte[] b, int off, int len)- Overrides:
writein classOutputStream
-
write
public void write(byte[] b)
- Overrides:
writein classOutputStream
-
close
public void close()
Packages any remaining data into aStreamPartand signals to theStreamTransferManagerthat there are no more parts afterwards. You cannot write to the stream after it has been closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-
-