Permalink
Browse files

Step 21.6: Create stores for Images and Thumbs

  • Loading branch information...
1 parent 19394df commit e31953b940b8c0afdaa4f17a2e21c38b4dfc05d7 @dotansimha dotansimha committed with DAB0mB Sep 27, 2016
Showing with 32 additions and 0 deletions.
  1. +32 −0 both/collections/images.collection.ts
@@ -1,6 +1,38 @@
import { MongoObservable } from 'meteor-rxjs';
import { Meteor } from 'meteor/meteor';
+import { UploadFS } from 'meteor/jalik:ufs';
import { Thumb, Image } from "../models/image.model";
export const Images = new MongoObservable.Collection<Image>('images');
export const Thumbs = new MongoObservable.Collection<Thumb>('thumbs');
+
+function loggedIn(userId) {
+ return !!userId;
+}
+
+export const ThumbsStore = new UploadFS.store.GridFS({
+ collection: Thumbs.collection,
+ name: 'thumbs',
+ permissions: new UploadFS.StorePermissions({
+ insert: loggedIn,
+ update: loggedIn,
+ remove: loggedIn
+ })
+});
+
+export const ImagesStore = new UploadFS.store.GridFS({
+ collection: Images.collection,
+ name: 'images',
+ filter: new UploadFS.Filter({
+ contentTypes: ['image/*']
+ }),
+ copyTo: [
+ ThumbsStore
+ ],
+ permissions: new UploadFS.StorePermissions({
+ insert: loggedIn,
+ update: loggedIn,
+ remove: loggedIn
+ })
+});
+

0 comments on commit e31953b

Please sign in to comment.