简体   繁体   English

Amazon S3 访问仅在 CopyObject 中被拒绝

[英]Amazon S3 Access Denied only in CopyObject

I'm upload files from nodejs script and when I try to copy object I'm getting Access Denied error, if I try to delete the object or to get it - there is no problem and it success.我正在从 nodejs 脚本上传文件,当我尝试复制对象时,如果我尝试删除对象或获取它,我会收到拒绝访问错误 - 没有问题并且它成功。

Is there anything spacial in the CopyObject? CopyObject 中是否有任何空间?

params = {
     "Bucket": "buacket-name",
     "CopySource": "source-path/object.txt",
     "Key": "source-path/object2.txt"
};

s3.copyObject(params, function(err, data)); // With a function for success or error.

Thanks.谢谢。

Solved it!解决了! The problem was in my CopySource path, it needs to have the bucket name first, like so: backet-name/objectkey问题出在我的 CopySource 路径中,它需要首先具有存储桶名称,如下所示:backet-name/objectkey

Per the AWS S3 copyObject docs , the CopySource parameter should include the bucket and key names.根据 AWS S3 copyObject docs , CopySource 参数应包括存储桶和密钥名称。 For example:例如:

var params = {
  CopySource: 'source_bucket/source_key',
  Bucket: 'destination_bucket_name',
  Key: 'destination_key'
};

s3.copyObject(params, function(error, data) {

  // error check
  if (error) {
    console.log(error, error.stack);
  }

  console.log('S3 object copied');
});

I had a similar issue to yours in that copyObject produced a 403 "Access Denied" response, but a getObject followed by a putObject worked fine.我遇到了与您类似的问题,因为copyObject产生了 403“拒绝访问”响应,但是getObject后跟putObject工作正常。 In my case, I did have the correct syntax for the CopySource parameter.在我的例子中,我确实有CopySource参数的正确语法。

The solution to my problem was to add the s3:GetObjectTagging and s3:PutObjectTagging permissions to the IAM role performing the copy, since the copyObject operation will attempt to copy the tags over.我的问题的解决方案是将s3:GetObjectTaggings3:PutObjectTagging权限添加到执行复制的 IAM 角色,因为 copyObject 操作将尝试复制标签。 I know this isn't the solution to your problem, but I'm putting this down answer in case someone else has something very similar.我知道这不是您问题的解决方案,但我将把这个答案记下来,以防其他人有非常相似的情况。

Unfortunately, the documentation for the Node.JS API and the S3 service do not mention this permission requirement.不幸的是, Node.JS APIS3 服务的文档没有提到这个权限要求。 I learned the solution in an SO answer .我在SO answer中学习了解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM