i want to forbid the upload / storage of files under special circumstances.
I tried in the collectionfs before hook:
Attachments.files.before.insert((userId, doc) => {
if(!Meteor.isServer){
if (!isUploadAllowed()) {
throw new Meteor.Error('Upload not allowed');
}
}
}
Unfortunately this is not working.
Is there a better way to achieve this? Or can someone help me?
(An ugly solution would be to remove the uploaded document in the after.insert hook, i hope there is a better way)
You can set the deny for this collection for all client operations to false:
const Attachments.files = new Mongo.Collection('fs.files')
Attachments.files.deny({
insert () { return true },
update () { return true },
remove () { return true }
})
This defaults to deny any client operation to sync with the server.