I'm new to programming in Meteor, I have been the whole day trying to figure this out without any luck. I'm using collectionFS to upload an image, I want to give it my Meteor.userId(); so that only logged in users can see their own images I have the following code:
'change .myFileInput': function(event, template) {
FS.Utility.eachFile(event, function(file) {
Imagess.insert(file, function (err, fileObj) {
if (err){
// handle error
} else {
// handle success depending what you need to do
var currentUserId = Meteor.userId();
var imagesURL = {
"profile.image": "/cfs/files/images/" + fileObj._id
};
Meteor.users.update(currentUserId, {$set: imagesURL});
}
});
});
},
I tried doing this but it won't work, it says access denied:
'change .myFileInput': function(event, template) {
FS.Utility.eachFile(event, function(file) {
Imagess.insert(file, function (err, fileObj) {
if (err){
// handle error
} else {
// handle success depending what you need to do
var currentUserId = Meteor.userId();
var imagesURL = {
"profile.image": "/cfs/files/images/" + fileObj._id
};
createdBy: currentUserId,
Meteor.users.update(currentUserId, {$set: imagesURL});
}
});
});
},
Any idea how can I get this done?
Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire