Dart Documentationmongo_dartGridFS

GridFS class

class GridFS {
 static int DEFAULT_CHUNKSIZE = 256 * 1024;
 static int MAX_CHUNKSIZE = (3.5 * 1000 * 1000).toInt();

 Db database;
 DbCollection files;
 DbCollection chunks;
 String bucketName;

 GridFS(Db this.database, [String collection="fs"]) {
   this.files = database.collection("$collection.files");
   this.chunks = database.collection("$collection.chunks");
   bucketName = collection;

   // TODO(tsander): Ensure index.
 }

 Cursor getFileList(SelectorBuilder selectorBuilder) {
   return files.find(selectorBuilder.sortBy("filename", descending:true));
 }

 Future<GridOut> findOne(dynamic selector) {
   Completer completer = new Completer();
   files.findOne(selector).then((Map file) {
     GridOut result = null;
     if (file != null) {
       result = new GridOut(file);
       result.setGridFS(this);
     }
     completer.complete(result);
   });
   return completer.future;
 }
 
 Future<GridOut> getFile(String fileName) => findOne(where.eq('filename',fileName));
 
 GridIn createFile(Stream<List<int>> input, String filename) {
   return new GridIn(this, filename, input);
 }
}

Static Properties

int DEFAULT_CHUNKSIZE #

static int DEFAULT_CHUNKSIZE = 256 * 1024

int MAX_CHUNKSIZE #

static int MAX_CHUNKSIZE = (3.5 * 1000 * 1000).toInt()

Constructors

new GridFS(Db database, [String collection = "fs"]) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
GridFS(Db this.database, [String collection="fs"]) {
 this.files = database.collection("$collection.files");
 this.chunks = database.collection("$collection.chunks");
 bucketName = collection;

 // TODO(tsander): Ensure index.
}

Properties

String bucketName #

String bucketName

DbCollection chunks #

DbCollection chunks

Db database #

Db database

DbCollection files #

DbCollection files

Methods

GridIn createFile(Stream<List<int>> input, String filename) #

GridIn createFile(Stream<List<int>> input, String filename) {
 return new GridIn(this, filename, input);
}

Future<GridOut> findOne(selector) #

Future<GridOut> findOne(dynamic selector) {
 Completer completer = new Completer();
 files.findOne(selector).then((Map file) {
   GridOut result = null;
   if (file != null) {
     result = new GridOut(file);
     result.setGridFS(this);
   }
   completer.complete(result);
 });
 return completer.future;
}

Future<GridOut> getFile(String fileName) #

Future<GridOut> getFile(String fileName) => findOne(where.eq('filename',fileName));

Cursor getFileList(SelectorBuilder selectorBuilder) #

Cursor getFileList(SelectorBuilder selectorBuilder) {
 return files.find(selectorBuilder.sortBy("filename", descending:true));
}