Search in sources :

Example 6 with GridFSFile

use of com.mongodb.client.gridfs.model.GridFSFile in project mongo-java-driver by mongodb.

the class GridFSUploadStreamImpl method close.

@Override
public void close() {
    synchronized (closeLock) {
        if (closed) {
            return;
        }
        closed = true;
    }
    writeChunk();
    GridFSFile gridFSFile = new GridFSFile(fileId, filename, lengthInBytes, chunkSizeBytes, new Date(), toHex(md5.digest()), metadata);
    filesCollection.insertOne(gridFSFile);
    buffer = null;
}
Also used : GridFSFile(com.mongodb.client.gridfs.model.GridFSFile) Date(java.util.Date)

Aggregations

GridFSFile (com.mongodb.client.gridfs.model.GridFSFile)6 Date (java.util.Date)3 Document (org.bson.Document)3 MongoGridFSException (com.mongodb.MongoGridFSException)2 BsonDocument (org.bson.BsonDocument)2 MongoClient (com.mongodb.MongoClient)1 MongoClientURI (com.mongodb.MongoClientURI)1 SingleResultCallback (com.mongodb.async.SingleResultCallback)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 GridFSBucket (com.mongodb.client.gridfs.GridFSBucket)1 GridFSDownloadStream (com.mongodb.client.gridfs.GridFSDownloadStream)1 GridFSUploadStream (com.mongodb.client.gridfs.GridFSUploadStream)1 GridFSDownloadOptions (com.mongodb.client.gridfs.model.GridFSDownloadOptions)1 GridFSUploadOptions (com.mongodb.client.gridfs.model.GridFSUploadOptions)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 BsonString (org.bson.BsonString)1 BsonValue (org.bson.BsonValue)1 ObjectId (org.bson.types.ObjectId)1