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 void
cleanup()
void
close()
void
flush()
long
getDiskLimit()
File
getFile(int partNumber)
String
getNamePrefix()
int
getNumFilesWritten()
long
getPartSize()
File
getRoot()
long
getTotalBytesWritten()
MultiFileOutputStream
init(UploadObjectObserver observer, long partSize, long diskLimit)
Used to initialize this stream.boolean
isClosed()
void
onFileDelete(FileDeletionEvent event)
Called upon a file deletion event.void
write(byte[] b)
This method would block as necessary if running out of disk space.void
write(byte[] b, int off, int len)
This method would block as necessary if running out of disk space.void
write(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 IOException
This method would block as necessary if running out of disk space.- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
This method would block as necessary if running out of disk space.- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
This method would block as necessary if running out of disk space.- Overrides:
write
in classOutputStream
- Throws:
IOException
-
onFileDelete
public void onFileDelete(FileDeletionEvent event)
Description copied from interface:OnFileDelete
Called upon a file deletion event.Implementation of this method should never block.
- Specified by:
onFileDelete
in interfaceOnFileDelete
- Parameters:
event
- file deletion event
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in 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()
-
-