I am using CollectionFS package to upload Images over my meteor application but not able to validate file using filters
, so far I can upload any file of any extension and of any size.
template
<template name="uploadPicture">
<label class="ui primary left labeled icon button" for="file" id="upload-div">
<i class="photo icon"></i>
Update Picture
<input type="file" id="file" class="myFileInput"/>
</label>
</template>
client/upload_picture.js
Template.uploadPicture.events({
'change .myFileInput': function (event) {
FS.Utility.eachFile(event, function(file) {
Images.insert(file, function (err, fileObj) {
// Inserted new doc with ID fileObj._id, and kicked off the data upload using HTTP
});
});
}
});
lib/collection/images.js is
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images")],
filters: {
maxSize: 1048576, // in bytes
allow: {
contentTypes: ['image/*'],
extensions: ['png','jpg','jpeg','gif']
},
onInvalid: function (message) {
if (Meteor.isClient) {
alert(message);
} else {
console.log(message);
}
}
}
});
Images.allow({
'insert': function () {
// add custom authentication code here
return true;
}
});
need to replace the key filters
with filter
, after that it will start working as normal