Reputation: 8792
Up until recently this code was working as expected, media files could be uploaded, saved into Mongo and then retrieved using their stores.
During a routine test of the system I noted that this has stopped working and we are getting Access denied [403]
errors anytime we try and upload media both locally and in production.
All my research suggests that setting insert/update/download to be true would work. To debug in the code below everything is set to true and I am still getting this 403
Any guidance would be hugely appreciated.
Media = new FS.Collection("media", {
stores: [
mediaStoreGrid,
mediaStoreGridThumbnail,
mediaStoreGridOptions,
mediaStoreGridLightbox,
mediaStoreGridLogo
]
});
Media.allow({
insert: function(userId, project) {
return true;
},
update: function(userId,project,fields,modifier) {
return false;
},
remove: function(userId,project) {
return true;
},
download: function() {
return true;
}
});
// We just care about the first file
var files = $('.descriptive-image').get(0).files;
if (files.length > 0) {
var media = Media.insert(files[0]);
Meteor.subscribe('mediaItem', media._id);
return [media._id];
} else {
return [];
}
Upvotes: 0
Views: 135
Reputation: 4703
FS.Collection insert takes an FS.File as the argument, not the raw file input object. Try this:
var mediaFile = new FS.File(files[0]);
var media = Media.insert(mediaFile);
Upvotes: 1