Meteor CollectionFS S3错误流图像访问被拒绝

Meteor CollectionFS S3错误流图像访问被拒绝,meteor,amazon-s3,collectionfs,Meteor,Amazon S3,Collectionfs,我正在尝试设置CollectionFS和S3,以便可以从AutoForm将文件上载到S3 我有一个Images FS.Collection,它是由服务器上的函数定义的,如下所示: // Client and server. var imageStore = new FS.Store.S3('images', { region: 'us-eas

我正在尝试设置CollectionFS和S3,以便可以从AutoForm将文件上载到S3

我有一个Images FS.Collection,它是由服务器上的
函数定义的,如下所示:

// Client and server.
var imageStore = new FS.Store.S3('images', {                                                                            
  region: 'us-east-1',                                                                                                  
  accessKeyId: 'mykey',                                                                                                                                            
  secretAccessKey: 'my/key',                                                          
  bucket: 'buketz',                                                                                               
  folder: 'images',                                                                                                     
});                                                                                                                     

Images = new FS.Collection('images', {                                                                                  
  stores: [imageStore],                                                                                                 
  filter: {                                                                                                             
    allow: {                                                                                                            
      contentTypes: ['image/*'],                                                                                        
      extensions: ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG']                                                          
    }                                                                                                                   
  }                                                                                                                     
});

// Server only.
Images.allow({                                                                                                                                                                    
  insert: function (userId, image) {                                                                                    
    return true;                                                                                                        
  },                                                                                                                    
  update: function (userId, image) {                                                                                    
    return true;                                                                                                        
  },                                                                                                                    
  remove: function (userId, image) {                                                                                    
    return true;                                                                                                        
  },                                                                                                                    
  download: function (userId, image) {                                                                                  
    return true;                                                                                                        
  }                                                                                                                     
}); 
现在,当我加载应用程序时,Metrot会向我抛出这个错误:

/Users/pcoffey/.meteor/packages/cfs_s3/.0.1.3.1ba5bia++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/request.js:32
          throw err;
                ^
Error: Error storing file to the images store: Access Denied
    at [object Object].<anonymous> (packages/cfs:collection/common.js:88:1)
    at [object Object].emit (events.js:106:17)
    at Writable.<anonymous> (packages/cfs:storage-adapter/storageAdapter.server.js:212:1)
    at Writable.emit (events.js:117:20)
    at Response.<anonymous> (packages/cfs:s3/s3.upload.stream2.js:178:1)
    at Request.<anonymous> (/Users/pcoffey/.meteor/packages/cfs_s3/.0.1.3.1ba5bia++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/request.js:350:18)
    at Request.callListeners (/Users/pcoffey/.meteor/packages/cfs_s3/.0.1.3.1ba5bia++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/sequential_executor.js:100:18)
    at Request.emit (/Users/pcoffey/.meteor/packages/cfs_s3/.0.1.3.1ba5bia++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Users/pcoffey/.meteor/packages/cfs_s3/.0.1.3.1ba5bia++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/request.js:604:14)
    at Request.transition (/Users/pcoffey/.meteor/packages/cfs_s3/.0.1.3.1ba5bia++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/request.js:21:12)
Exited with code: 8
FileWorker ADDED - calling saveCopy images for o5pjjrGD9AfHJwHZG
saving to store images
createWriteStream images, internal: false
createWriteStreamForFileKey images
Meteor._wrapAsync has been renamed to Meteor.wrapAsync
TempStore is mounted on storage.gridfs
FS.TempStore creating read stream for o5pjjrGD9AfHJwHZG
createReadStream _tempstore
createReadStreamForFileKey _tempstore
GRIDFS { _id: 5584b2140cac49f4312c1425, root: 'cfs_gridfs._tempstore' }
FS.HTTP.unmount:
{}
Registered HTTP method URLs:
/cfs/files/:collectionName/:id/:filename
/cfs/files/:collectionName/:id
/cfs/files/:collectionName
=> Meteor server restarted
-----------ERROR STREAM images Access Denied
-----------ERROR STREAM images Access Denied

如果我更改集合名称,它将临时加载,但一旦我尝试进行文件上载,错误将再次启动。有人知道是什么导致了这个问题吗?

听起来像是AWS权限的问题。你做了吗?

我得到了这样的设置,对我来说非常好。我使用以下软件包:

 cfs:standard-packages
 cfs:filesystem
 cfs:s3
 cfs:graphicsmagick
//客户端代码

var companyLogoStore = new FS.Store.S3( "companyLogo" );
Images = new FS.Collection( "images", {
  stores: [ companyLogoStore ],
  filter: {
    maxSize: 5242880, // in bytes
    allow: {
        contentTypes: [ 'image/*' ],
        extensions: [ 'png', 'bmp', 'jpeg', 'gif', 'webp', 'jpg' ]
    }
  },
  onInvalid: function ( message ) {
    if ( Meteor.isClient ) {
        Alerts.add( message, 'danger' );
    } else {
        console.log( message );
    }
  }
} );
 var companyLogoStore = new FS.Store.S3("companyLogo", {
  region: "xxxxxx", 
  accessKeyId: "xxxxxxx",
  secretAccessKey: "xxxxxxxx",
  bucket: "xxxxxxx",
  ACL: "public-read", **//optional, default is 'private', but you can allow public or secure access routed through your app URL**
  fileKeyMaker: function (fileObj) {
    return 'uploads/company/' + fileObj.original.name;
  },
  transformWrite: function(fileObj, readStream, writeStream) {
    gm(readStream, fileObj.name()).resize('210', '210').stream().pipe(writeStream);
  },
  maxTries: 3 //optional, default 5
 });
//服务器端代码

var companyLogoStore = new FS.Store.S3( "companyLogo" );
Images = new FS.Collection( "images", {
  stores: [ companyLogoStore ],
  filter: {
    maxSize: 5242880, // in bytes
    allow: {
        contentTypes: [ 'image/*' ],
        extensions: [ 'png', 'bmp', 'jpeg', 'gif', 'webp', 'jpg' ]
    }
  },
  onInvalid: function ( message ) {
    if ( Meteor.isClient ) {
        Alerts.add( message, 'danger' );
    } else {
        console.log( message );
    }
  }
} );
 var companyLogoStore = new FS.Store.S3("companyLogo", {
  region: "xxxxxx", 
  accessKeyId: "xxxxxxx",
  secretAccessKey: "xxxxxxxx",
  bucket: "xxxxxxx",
  ACL: "public-read", **//optional, default is 'private', but you can allow public or secure access routed through your app URL**
  fileKeyMaker: function (fileObj) {
    return 'uploads/company/' + fileObj.original.name;
  },
  transformWrite: function(fileObj, readStream, writeStream) {
    gm(readStream, fileObj.name()).resize('210', '210').stream().pipe(writeStream);
  },
  maxTries: 3 //optional, default 5
 });
我还使用ongoworks:security包获得权限

Images.files.permit(['insert','update','remove']).ifHasRole(['admin', 'manager']).apply();

我知道这可能没有帮助,但您是否尝试过slingshot meteor软件包()?这在设计上优于CFS,因为它不使用服务器传输文件,而是允许您直接将文件发送到AWS,而不泄露您的秘密。但是,它无法解决您的AWS权限问题。我确实进行了设置,但可能遗漏了一些内容。