meteor S3 file upload not working at server code i am using cfs:s3

392 views Asked by At

I have added three package

cfs:standard-packages
cfs:filesystem
cfs:s3

error :

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;
}    
 });

server js

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

this keep give me error for upload TypeError: Cannot read property 'keys' of undefined

but if i move server code to client.js it do upload file on S3. what's problem with Upload on S3 from server code.

can You please help me to resolve this error. how we can get out of this error what's wrong with my code or config.

TypeError: Cannot read property 'keys' of undefined
2

There are 2 answers

2
etmarch On

Is it possible that it is a syntax error?

You are missing " at the end of this line: bucket: "temp, //required

0
Danil On

Hi try putting your permission "allow" rule on the server side https://github.com/CollectionFS/Meteor-CollectionFS#storage-adapters

filestore.allow({
    insert: function () {
        return true;
    },
    update: function () {
        return true;
    },
    remove: function () {
        return true;
    },
    download: function(){
        return true;
    }
});