summaryrefslogtreecommitdiffstats
path: root/collections/avatars.js
diff options
context:
space:
mode:
Diffstat (limited to 'collections/avatars.js')
-rw-r--r--collections/avatars.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/collections/avatars.js b/collections/avatars.js
new file mode 100644
index 00000000..5ca074ee
--- /dev/null
+++ b/collections/avatars.js
@@ -0,0 +1,27 @@
+Avatars = new FS.Collection('avatars', {
+ stores: [
+ new FS.Store.GridFS('avatars')
+ ],
+ filter: {
+ maxSize: 32000,
+ allow: {
+ contentTypes: ['image/*']
+ }
+ }
+});
+
+var isOwner = function(userId, file) {
+ return userId && userId === file.userId;
+};
+
+Avatars.allow({
+ insert: isOwner,
+ update: isOwner,
+ remove: isOwner,
+ download: function() { return true; },
+ fetch: ['userId']
+});
+
+Avatars.files.before.insert(function(userId, doc) {
+ doc.userId = userId;
+});