-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step 21.6: Create stores for Images and Thumbs
- Loading branch information
1 parent
19394df
commit e31953b
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}) | ||
}); | ||
|