mirror of
https://github.com/wekan/wekan.git
synced 2026-01-25 18:56:10 +01:00
fixup! Ref: Avatars to use modern gridfs
This commit is contained in:
parent
f244125cd3
commit
7b64c8b235
1 changed files with 13 additions and 8 deletions
|
|
@ -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({
|
if (Meteor.isServer) {
|
||||||
insert: isOwner,
|
Avatars.allow({
|
||||||
update: isOwner,
|
insert: isOwner,
|
||||||
remove: isOwner,
|
update: isOwner,
|
||||||
fetch: ['userId'],
|
remove: isOwner,
|
||||||
});
|
fetch: ['userId'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default Avatars;
|
export default Avatars;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue