为什么AWS S3返回错误消息访问被拒绝?

时间:2018-09-29 19:35:06

标签: node.js amazon-web-services amazon-s3 aws-sdk

当我在aws s3中上传文件时,它会向我返回此错误

const data = [
 {'a':123,'b':345,'c':{'b1':1,'b2':2,'b3':3}},
 {'a':234,'b':456,'c':{'b1':2,'b2':4,'b3':6}},
 {'a':345,'b':567,'c':{'b1':3,'b2':6,'b3':9}}
];

const sumProps = (o) =>
  Object.values(o) // get the values of an object
    .reduce((r, v) => // iterate the values
      r + (typeof v === 'object' ? sumProps(v) : v) // add the values to the previous sum, and if the values are an object sum it recursively
    , 0);

// iterate the objects with map
const result = data.map(({ a, ...rest }) => { // destructure a, and an object of all other params
  return ({ // combine them back to an object
    a,
    ...rest, // spread the rest object
    d: sumProps(rest) // get the sum of the rest, and assign to d
  });
});

console.log(result);

我使用Node js。

1 个答案:

答案 0 :(得分:1)

以下是S3访问AccessDenied的可能原因:

  1. 与凭据关联的政策不允许访问
  2. 与存储桶相关的政策会拒绝访问
  3. 对象不存在
  4. 对象已通过KMS加密,您未提供KMS密钥
  5. 对象位于另一个帐户中,并且您的跨帐户权限不允许访问
  6. VPC终结点策略
  7. 在存储桶上启用了请求者付款
  8. AWS Organizations服务控制策略不允许访问

还有关于how to troubleshoot 403 Access Denied的一些想法。