[英]How do I use the aws cli to set permissions on files in an S3 bucket?
I am new to the aws cli and I've spent a fair amount of time in the documentation but I can't figure out how to set permissions on files after I've uploaded them.我是 aws cli 的新手,我在文档中花了很多时间,但在上传文件后我不知道如何设置文件的权限。 So if I uploaded a file with:
所以如果我上传了一个文件:
aws s3 cp assets/js/d3-4.3.0.js s3://example.example.com/assets/js/
and didn't set access permissions, I need a way to set them.并且没有设置访问权限,我需要一种方法来设置它们。 Is there an equivalent to
chmod 644
in the aws cli? aws cli 中是否有等效于
chmod 644
的内容?
And for that matter is there a way to view access permission?就此而言,有没有办法查看访问权限?
I know I could use the --acl public-read
flag with aws s3 cp
but if I didn't, can I set access without repeating the full copy command?我知道我可以将
--acl public-read
标志与aws s3 cp
但如果我不这样做,我可以在不重复完整复制命令的情况下设置访问权限吗?
The awscli supports two groups of S3 actions: s3 and s3api . awscli 支持两组 S3 操作: s3和s3api 。
You can use aws s3api put-object-acl to set the ACL permissions on an existing object.您可以使用aws s3api put-object-acl来设置现有对象的 ACL 权限。
The logic behind there being two sets of actions is as follows: 两组动作背后的逻辑如下:
s3
: high-level abstractions with file system-like features such as ls
, cp
, sync
s3
:具有类似文件系统功能的高级抽象,例如ls
、 cp
、 sync
s3api
: one-to-one with the low-level S3 APIs such as put-object
, head-bucket
s3api
:与低级 S3 API(例如put-object
、 head-bucket
一对一In your case, the command to execute is:在您的情况下,要执行的命令是:
aws s3api put-object-acl --bucket example.example.com --key assets/js/d3-4.3.0.js --acl public-read
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.