cluster0:cfs-gridfs

v0.1.3Published 3 months ago

meanware:gridfs

NOTE: This package is just a small update on cfs:gridfs. The original package seems not to be maintained anymore and will not work with a mongodb 3.4 Atlas Cluster. This is fixed by updating the database drivers.

A Meteor package that adds GridFS file storage for CollectionFS. When you use this storage adapter, file data is stored in chunks in your MongoDB database.

Installation

Install using Meteorite. When in a Meteor app directory, enter:

$ meteor add meanware:gridfs

Usage

1var imageStore = new FS.Store.GridFS("images", {
2  mongoUrl: 'mongodb://127.0.0.1:27017/test/', // optional, defaults to Meteor's local MongoDB
3  mongoOptions: {...},  // optional, see note below
4  transformWrite: myTransformWriteFunction, //optional
5  transformRead: myTransformReadFunction, //optional
6  maxTries: 1, // optional, default 5
7  chunkSize: 1024*1024  // optional, default GridFS chunk size in bytes (can be overridden per file).
8                        // Default: 2MB. Reasonable range: 512KB - 4MB
9});
10
11Images = new FS.Collection("images", {
12  stores: [imageStore]
13});

More control over the MongoDB connection is available by specifying MongoClient.connect options as a mongoOptions attribute in the options object on the constructor.

Refer to the CollectionFS package documentation for more information.

API

For Users

For Contributors