meteor S3文件上传不在服务器代码我正在使用cfs:s3

时间:2015-06-16 13:22:29

标签: javascript meteor amazon-s3 meteor-collections

我添加了三个包

cfs:standard-packages
cfs:filesystem
cfs:s3

错误:

TypeError: Cannot read property 'keys' of undefined

s3.js

var avatarStoreLarge = new FS.Store.S3("temp", {
    region: "eu-west-1", //optional in most cases
    accessKeyId: "XXX", //required if environment variables are not set
    secretAccessKey: "XX", //required if environment variables are not set
    bucket: "temp", //required
    ACL:'public-read-write'
});
var filestore = new FS.Collection("temp", {
    stores: [avatarStoreLarge]
});

client.js

var avatarStoreLarge = new FS.Store.S3("temp")
var filestore = new FS.Collection("temp", {
    stores: [avatarStoreLarge]
})
filestore.allow({
    insert: function () {
        return true;
    },
    update: function () {
        return true;
    },
    remove: function () {
        return true;
    },
    download: function(){
        return true;
    }
});
filestore.deny({
 insert: function(){
   return false;
 },
 update: function(){
   return false;
 },
 remove: function(){
   return false;
 },
 download: function(){
   return false;
}    
 });

服务器js

        var fsFile = new FS.File(fileContent);
        fsFile.metadata = {owner: Meteor.user()._id};
        filestore.insert(fsFile});

这个继续给我上传错误 TypeError:无法读取属性'键'未定义的

但如果我将服务器代码移动到client.js,它会在S3上传文件。 从服务器代码上S3上载的问题。

你能帮我解决这个错误吗? 我们如何摆脱这个错误我的代码或配置有什么问题。

TypeError: Cannot read property 'keys' of undefined

2 个答案:

答案 0 :(得分:0)

是否可能是语法错误?

您在此行末尾缺少"bucket: "temp, //required

答案 1 :(得分:0)

您可以尝试在服务器端放置您的权限“允许”规则 https://github.com/CollectionFS/Meteor-CollectionFS#storage-adapters

    } else {
        int guess = primes.pop();
        myCurrentGuess = guess;
        return guess;
    }
}