本文介绍了如何使用 AWS s3 或 AWS s3api 递归更改文件夹的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向 s3 中的现有帐户授予权限.

I am trying to grant permissions to an existing account in s3.

该存储桶归该帐户所有,但数据是从另一个帐户的存储桶复制的.

The bucket is owned by the account, but the data was copied from another account's bucket.

当我尝试使用命令授予权限时:

When I try to grant permissions with the command:

aws s3api put-object-acl --bucket <bucket_name> --key <folder_name> --profile <original_account_profile> --grant-full-control emailaddress=<destination_account_email>

我收到错误:

An error occurred (NoSuchKey) when calling the PutObjectAcl operation: The specified key does not exist.

而如果我在单个文件上执行该命令则成功.

while if I do it on a single file the command is successful.

如何使它适用于整个文件夹?

How can I make it work for a full folder?

推荐答案

您需要为每个对象单独运行命令.

You will need to run the command individually for every object.

您可以使用以下方法缩短流程:

You might be able to short-cut the process by using:

aws s3 cp --acl bucket-owner-full-control --metadata Key=Value --profile <original_account_profile> s3://bucket/path s3://bucket/path

也就是说,您将文件复制到自身,但添加了向存储桶所有者授予权限的 ACL.

That is, you copy the files to themselves, but with the added ACL that grants permissions to the bucket owner.

如果您有子目录,则添加--recursive.

If you have sub-directories, then add --recursive.

这篇关于如何使用 AWS s3 或 AWS s3api 递归更改文件夹的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 13:04