【发布时间】:2015-05-17 20:41:15
【问题描述】:
我正在尝试使用this 指南测试上传功能,唯一的例外是使用cfs-s3 包。这是非常基本的简单代码,但我在客户端控制台上遇到错误 - Error: Access denied. No allow validators set on restricted collection for method 'insert'. [403]
即使我以各种可能的方式设置了allow insert,我仍然收到此错误。
这是我的客户端代码:
// client/images.js
var imageStore = new FS.Store.S3("images");
Images = new FS.Collection("images", {
stores: [imageStore],
filter: {
allow: {
contentTypes: ['image/*']
}
}
});
Images.deny({
insert: function(){
return false;
},
update: function(){
return false;
},
remove: function(){
return false;
},
download: function(){
return false;
}
});
Images.allow({
insert: function(){
return true;
},
update: function(){
return true;
},
remove: function(){
return true;
},
download: function(){
return true;
}
});
而且首页有一个简单的文件输入按钮-
// client/home.js
'change .myFileInput': function(e, t) {
FS.Utility.eachFile(e, function(file) {
Images.insert(file, function (err, fileObj) {
if (err){
console.log(err) // --- THIS is the error
} else {
// handle success depending what you need to do
console.log("fileObj id: " + fileObj._id)
//Meteor.users.update(userId, {$set: imagesURL});
}
});
});
}
我已经在 S3 上设置了正确的策略和所有内容,但我认为此错误与 S3 完全无关。
// server/images.js
var imageStore = new FS.Store.S3("images", {
accessKeyId: "xxxx",
secretAccessKey: "xxxx",
bucket: "www.mybucket.com"
});
Images = new FS.Collection("images", {
stores: [imageStore],
filter: {
allow: {
contentTypes: ['image/*']
}
}
});
我还适当地发布和订阅了这些集合。我已经挖掘了几个小时,但似乎无法弄清楚发生了什么。
编辑:我刚刚阅读了insecure 包,现在一切正常。所以基本上,问题在于允许/拒绝规则,但我实际上正在这样做。我不知道为什么它不承认规则。
【问题讨论】:
标签: javascript file-upload meteor amazon-s3