Class MultiFileOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- software.amazon.encryption.s3.internal.MultiFileOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,OnFileDelete
public class MultiFileOutputStream extends OutputStream implements OnFileDelete
-
-
Constructor Summary
Constructors Constructor Description MultiFileOutputStream()Construct an instance to use the default temporary directory and temp file naming convention.MultiFileOutputStream(File root, String namePrefix)Construct an instance to use the specified directory for temp file creations, and the specified prefix for temp file naming.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanup()voidclose()voidflush()longgetDiskLimit()FilegetFile(int partNumber)StringgetNamePrefix()intgetNumFilesWritten()longgetPartSize()FilegetRoot()longgetTotalBytesWritten()MultiFileOutputStreaminit(UploadObjectObserver observer, long partSize, long diskLimit)Used to initialize this stream.booleanisClosed()voidonFileDelete(FileDeletionEvent event)Called upon a file deletion event.voidwrite(byte[] b)This method would block as necessary if running out of disk space.voidwrite(byte[] b, int off, int len)This method would block as necessary if running out of disk space.voidwrite(int b)This method would block as necessary if running out of disk space.
-
-
-
Constructor Detail
-
MultiFileOutputStream
public MultiFileOutputStream()
Construct an instance to use the default temporary directory and temp file naming convention. Theinit(UploadObjectObserver, long, long)must be called before this stream is considered fully initialized.
-
MultiFileOutputStream
public MultiFileOutputStream(File root, String namePrefix)
Construct an instance to use the specified directory for temp file creations, and the specified prefix for temp file naming. Theinit(UploadObjectObserver, long, long)must be called before this stream is considered fully initialized.
-
-
Method Detail
-
init
public MultiFileOutputStream init(UploadObjectObserver observer, long partSize, long diskLimit)
Used to initialize this stream. This method is an SPI (service provider interface) that is called fromS3EncryptionClient.Implementation of this method should never block.
- Parameters:
observer- the upload object observerpartSize- part size for multipart uploaddiskLimit- the maximum disk space to be used for this multipart upload- Returns:
- this object
-
write
public void write(int b) throws IOExceptionThis method would block as necessary if running out of disk space.- Specified by:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b) throws IOExceptionThis method would block as necessary if running out of disk space.- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOExceptionThis method would block as necessary if running out of disk space.- Overrides:
writein classOutputStream- Throws:
IOException
-
onFileDelete
public void onFileDelete(FileDeletionEvent event)
Description copied from interface:OnFileDeleteCalled upon a file deletion event.Implementation of this method should never block.
- Specified by:
onFileDeletein interfaceOnFileDelete- Parameters:
event- file deletion event
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
cleanup
public void cleanup()
-
getNumFilesWritten
public int getNumFilesWritten()
- Returns:
- the number of files written with the specified prefix with the part number as the file extension.
-
getFile
public File getFile(int partNumber)
-
getPartSize
public long getPartSize()
-
getRoot
public File getRoot()
-
getNamePrefix
public String getNamePrefix()
-
getTotalBytesWritten
public long getTotalBytesWritten()
-
isClosed
public boolean isClosed()
-
getDiskLimit
public long getDiskLimit()
-
-