2
0
Эх сурвалжийг харах

fixup! Ref: Avatars to use modern gridfs

David Arnold 4 жил өмнө
parent
commit
6f995a5bdd
1 өөрчлөгдсөн 13 нэмэгдсэн , 8 устгасан
  1. 13 8
      models/avatars.js

+ 13 - 8
models/avatars.js

@@ -5,12 +5,15 @@ import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
 import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
 import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
 import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
 import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
 
 
-const avatarsBucket = createBucket('avatars');
+let avatarsBucket;
+if (Meteor.isServer) {
+  avatarsBucket = createBucket('avatars');
+}
 
 
 const Avatars = new FilesCollection({
 const Avatars = new FilesCollection({
   debug: false, // Change to `true` for debugging
   debug: false, // Change to `true` for debugging
   collectionName: 'avatars',
   collectionName: 'avatars',
-  allowClientCode: false,
+  allowClientCode: true,
   onBeforeUpload(file) {
   onBeforeUpload(file) {
     if (file.size <= 72000 && file.isImage) return true;
     if (file.size <= 72000 && file.isImage) return true;
     return 'Please upload image, with size equal or less than 72KB';
     return 'Please upload image, with size equal or less than 72KB';
@@ -24,11 +27,13 @@ function isOwner(userId, doc) {
   return userId && userId === doc.userId;
   return userId && userId === doc.userId;
 }
 }
 
 
-Avatars.allow({
-  insert: isOwner,
-  update: isOwner,
-  remove: isOwner,
-  fetch: ['userId'],
-});
+if (Meteor.isServer) {
+  Avatars.allow({
+    insert: isOwner,
+    update: isOwner,
+    remove: isOwner,
+    fetch: ['userId'],
+  });
+}
 
 
 export default Avatars;
 export default Avatars;