管理存储桶 ACL - bucket-acl

2025-11-07   访问量:0


注意:

如需查询存储桶 ACL,在您进行 授权策略 时,action 需要设置为 cos:GetBucketACL

如需设置存储桶 ACL,在您进行 授权策略 时,action 需要设置为 cos:PutBucketACL

更多授权请参见 支持 CAM 的业务接口

命令格式

./coscli bucket-acl --method [method] cos://<bucket-name>

bucket-acl 命令包含以下参数:

参数格式

参数用途

示例

cos://<bucket-name>

指定需要访问的存储桶。支持使用 配置参数 中的桶别名,或桶名称进行访问。如使用桶名称访问,需要额外携带 endpoint flag。

使用桶别名访问:cos://example-alias

使用桶名称访问:cos://examplebucket-1250000000

bucket-acl 命令包含以下可选 flag:

flag 简写

flag 全称

flag 用途

-h

--help

查看该命令的具体用法。

--method

指定需要进行的操作,包括 put(设置存储桶 ACL)、get(查询存储桶 ACL)。

--acl

设置文件的 ACL,例如 private,public-read,public-read-write。

--grant-read

赋予被授权者读取存储桶的权限,格式为 id="[OwnerUin]",例如 id="100000000001",可使用半角逗号(,)分隔多组被授权者,例如 id="100000000001",id="100000000002"。

--grant-read-acp

赋予被授权者读取存储桶的访问控制列表(ACL)的权限,格式为 id="[OwnerUin]",例如 id="100000000001",可使用半角逗号(,)分隔多组被授权者,例如 id="100000000001",id="100000000002"。

--grant-write-acp

赋予被授权者写入存储桶的访问控制列表(ACL)的权限,格式为 id="[OwnerUin]",例如 id="100000000001",可使用半角逗号(,)分隔多组被授权者,例如 id="100000000001",id="100000000002"。

--grant-full-control

赋予被授权者操作存储桶的所有权限,格式为 id="[OwnerUin]",例如 id="100000000001",可使用半角逗号(,)分隔多组被授权者,例如 id="100000000001",id="100000000002"。

说明:

关于此命令的其他通用选项(例如切换存储桶、切换用户账号等),请参见 通用选项 文档。

设置存储桶 ACL

操作示例

赋予100000000013、100000000012读取桶别名为 example-alias 的权限。命令如下:

./coscli bucket-acl --method put cos://example-alias --grant-read="id=\"100000000013\",id=\"100000000012\""

查询存储桶 ACL

操作示例

查询桶别名为 example-alias 的权限列表。

./coscli bucket-acl --method get cos://example-alias 

输出以下结果。

  SECTION  | KEY          | VALUE                                        

-----------+--------------+----------------------------------------------

 Owner    | UIN          |                                              

+          +--------------+---------------------------------------------+

          | ID           | qcs::cam::uin/100000000:uin/100000000      

+          +--------------+                                             +

          | Display Name |                                              

+----------+--------------+---------------------------------------------+

          |              |                                              

+----------+--------------+---------------------------------------------+

 Grant #1 | Permission   | READ                                        

+          +--------------+---------------------------------------------+

          | Grantee Type | CanonicalUser                                

+          +--------------+---------------------------------------------+

          | ID           | qcs::cam::uin/100000000013:uin/100000000013  

+          +--------------+                                             +

          | Display Name |                                              

+----------+--------------+---------------------------------------------+

          |              |                                              

+----------+--------------+---------------------------------------------+

 Grant #2 | Permission   | READ                                        

+          +--------------+---------------------------------------------+

          | Grantee Type | CanonicalUser                                

+          +--------------+---------------------------------------------+

          | ID           | qcs::cam::uin/100000000012:uin/100000000012  

+          +--------------+                                             +

          | Display Name |                                                                                

-----------+--------------+----------------------------------------------

Access Control List (ACL) Information



Summary:

- Owner: qcs::cam::uin/100000000:uin/100000000 (UIN: )

- Total Grants: 2

- Permissions:

  - READ: 2 grants




热门文章
更多>