majus:files-gridfs

v0.0.1Published 2 years ago

Overview

This is an extension of the API exported from ostrio:files Meteor package which allows to bypass the filesystem and store the uploaded files directly to the GridFS of MongoDB.

Installing

meteor add majus:files-gridfs

Using

1import { GridFilesCollection } from 'meteor/majus:files-gridfs';
2
3// Now just use GridFilesCollection in place of FilesCollection from ostrio:files
4const Avatars = new GridFilesCollection({
5  collectionName: 'avatars',
6  allowClientCode: true,
7  onBeforeUpload(file) {
8    if (file.size <= 72000 && file.type.startsWith('image/')) {
9      return true;
10    }
11    return 'avatar-too-big';
12  },
13});

Testing

npm install
npm test