AWS S3:在上载期间完全控制的情况下拒绝接收访问

时间:2018-12-12 08:28:11

标签: javascript node.js amazon-web-services api amazon-s3

我正在实现文件上传,并且有以下代码:

params = {
 Bucket: 'mybuck'
};
AWS.getBucketAcl(params, function(err, data) {
 if (err) console.log(err, err.stack);
    else console.log(data);      
});

params = {
 Key: 'testfile',
 Bucket: 'mybuck',
 Body: 'testcontent',
};
AWS.upload(params, (err, data) => {
 if (err) console.log(err);
   else console.log(key);
});

第一个请求返回“权限:完全控制权”,第二个请求给我AccessDenied错误:

> message: 'Access Denied', 
> code: 'AccessDenied',
> region: null,
> time: 2018-12-12T08:19:39.534Z
> requestId: '.....'
> extendedRequestId: '.....'
> cfId: undefined
> statusCode: 403

有人知道问题出在哪里吗?谢谢!

EDIT1: ACL查询的整个输出为:

{ Owner: { ID: '<censored>' },Grants: [ { Grantee: [Object], Permission: 'FULL_CONTROL' } ] }

2 个答案:

答案 0 :(得分:0)

您想添加accessKeyIdsecretAccessKey

//S3 configuraton
var s3 = new aws.S3({ 
    accessKeyId: '', 
    secretAccessKey: ''
}); 

s3.getObject(params, function(err, data) {

});

答案 1 :(得分:0)

因此问题出在AWS IAM策略中。我有完全的控制权,但是我没有权限处理对象。添加这些权限即可解决问题。

相关问题