final class GridFSUploadStreamImpl extends java.lang.Object implements GridFSUploadStream
Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer |
private int |
bufferOffset |
private boolean |
checkedIndexes |
private int |
chunkIndex |
private MongoCollection<Document> |
chunksCollection |
private int |
chunkSizeBytes |
private java.lang.Object |
closeAndWritingLock |
private boolean |
closed |
private BsonValue |
fileId |
private java.lang.String |
filename |
private MongoCollection<GridFSFile> |
filesCollection |
private GridFSIndexCheck |
indexCheck |
private long |
lengthInBytes |
private static Logger |
LOGGER |
private java.security.MessageDigest |
md5 |
private Document |
metadata |
private boolean |
writing |
Constructor and Description |
---|
GridFSUploadStreamImpl(MongoCollection<GridFSFile> filesCollection,
MongoCollection<Document> chunksCollection,
BsonValue fileId,
java.lang.String filename,
int chunkSizeBytes,
Document metadata,
GridFSIndexCheck indexCheck) |
Modifier and Type | Method and Description |
---|---|
void |
abort(SingleResultCallback<java.lang.Void> callback)
Aborts the upload and deletes any data.
|
private <T> void |
callbackClosedException(SingleResultCallback<T> callback) |
private <T> void |
callbackIsWritingException(SingleResultCallback<T> callback) |
private boolean |
checkClosed() |
void |
close(SingleResultCallback<java.lang.Void> callback)
Closes the output stream
|
private boolean |
getAndSetWritingLock() |
private Binary |
getData() |
private static java.security.MessageDigest |
getDigest() |
BsonValue |
getId()
The
BsonValue id for this file. |
ObjectId |
getObjectId()
Gets the
ObjectId for the file to be uploaded
Throws a MongoGridFSException if the file id is not an ObjectId. |
private void |
releaseWritingLock() |
private <T> boolean |
takeWritingLock(SingleResultCallback<T> errHandlingCallback) |
void |
write(java.nio.ByteBuffer src,
SingleResultCallback<java.lang.Integer> callback)
Writes a sequence of bytes from the given buffer into this stream.
|
private void |
write(int amount,
java.nio.ByteBuffer src,
SingleResultCallback<java.lang.Integer> callback) |
private void |
writeChunk(SingleResultCallback<java.lang.Void> callback) |
private static final Logger LOGGER
private final MongoCollection<GridFSFile> filesCollection
private final MongoCollection<Document> chunksCollection
private final BsonValue fileId
private final java.lang.String filename
private final int chunkSizeBytes
private final Document metadata
private final java.security.MessageDigest md5
private final GridFSIndexCheck indexCheck
private final java.lang.Object closeAndWritingLock
private boolean checkedIndexes
private boolean writing
private boolean closed
private byte[] buffer
private long lengthInBytes
private int bufferOffset
private int chunkIndex
GridFSUploadStreamImpl(MongoCollection<GridFSFile> filesCollection, MongoCollection<Document> chunksCollection, BsonValue fileId, java.lang.String filename, int chunkSizeBytes, Document metadata, GridFSIndexCheck indexCheck)
public ObjectId getObjectId()
GridFSUploadStream
ObjectId
for the file to be uploaded
Throws a MongoGridFSException
if the file id is not an ObjectId.getObjectId
in interface GridFSUploadStream
public BsonValue getId()
GridFSUploadStream
BsonValue
id for this file.getId
in interface GridFSUploadStream
public void abort(SingleResultCallback<java.lang.Void> callback)
GridFSUploadStream
abort
in interface GridFSUploadStream
callback
- the callback that is triggered when the abort and cleanup has finishedpublic void write(java.nio.ByteBuffer src, SingleResultCallback<java.lang.Integer> callback)
AsyncOutputStream
write
in interface AsyncOutputStream
src
- the source buffer containing the data to be written.callback
- the callback returning the number of bytes written.public void close(SingleResultCallback<java.lang.Void> callback)
AsyncOutputStream
close
in interface AsyncOutputStream
callback
- the callback that indicates when the stream has been closedprivate void write(int amount, java.nio.ByteBuffer src, SingleResultCallback<java.lang.Integer> callback)
private <T> boolean takeWritingLock(SingleResultCallback<T> errHandlingCallback)
private void writeChunk(SingleResultCallback<java.lang.Void> callback)
private Binary getData()
private boolean checkClosed()
private boolean getAndSetWritingLock()
private void releaseWritingLock()
private <T> void callbackClosedException(SingleResultCallback<T> callback)
private <T> void callbackIsWritingException(SingleResultCallback<T> callback)
private static java.security.MessageDigest getDigest()