mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
27 lines
489 B
JavaScript
27 lines
489 B
JavaScript
Avatars = new FS.Collection('avatars', {
|
|
stores: [
|
|
new FS.Store.GridFS('avatars')
|
|
],
|
|
filter: {
|
|
maxSize: 72000,
|
|
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;
|
|
});
|