设置桶ACL
功能说明
设置桶的访问权限。
方法定义
1. ObsClient->setBucketAcl(array $parameter) 2. ObsClient->setBucketAclAsync(array $parameter, callable $callback)
请求参数
字段名 | 类型 | 约束 | 说明 | ||
|---|---|---|---|---|---|
Bucket | string | 必选 | 桶名。 | ||
ACL | string | 可选 | |||
Owner | associative array | 可选 | 桶的所有者。 | ||
- | ID | string | 必选 | 桶所有者的DomainId。 | |
DisplayName | string | 可选 | 桶所有者的名字。 | ||
Grants | indexed array | 可选 | 被授权用户权限信息列表。 | ||
- | Grantee | associative array | 必选 | 被授权用户。 | |
- | Type | string | 必选 | 被授权的用户类型。 | |
ID | string | 如果Type为“CanonicalUser”则必选,否则必须为空 | 被授权用户的DomainId。 | ||
URI | string | 如果Type为“Group”则必选,否则必须为空 | 被授权的用户组。 | ||
Permission | string | 必选 | 被授予的权限。 | ||
Delivered | boolean | 可选 | 桶内对象ACL是否继承桶的ACL。 | ||

- Owner和Grants必须配套使用,且与ACL互斥。当设置了这两个字段时,不能设置ACL;反之,当设置了ACL时,不能设置Owner和Grants。
- Owner、Grants与ACL不能全为空。
返回结果
字段名 | 类型 | 说明 |
|---|---|---|
HttpStatusCode | integer | HTTP状态码。 |
Reason | string | HTTP文本描述。 |
RequestId | string | OBS服务端返回的请求ID。 |
代码样例
try{
$resp = $obsClient -> setBucketAcl([
'Bucket' => 'bucketname',
'Owner' => ['ID' => 'ownerid', 'DisplayName' => 'ownername'],
'Grants' => [
['Grantee' => ['Type' => 'CanonicalUser', 'ID' => 'userid'], 'Permission' => ObsClient::PermissionRead],
['Grantee' => ['Type' => 'CanonicalUser', 'ID' => 'userid'], 'Permission' => ObsClient::PermissionWrite],
['Grantee' => ['Type' => 'Group', 'URI' => ObsClient::GroupLogDelivery], 'Permission' => ObsClient::PermissionWrite],
['Grantee' => ['Type' => 'Group', 'URI' => ObsClient::GroupLogDelivery], 'Permission' => ObsClient::PermissionReadAcp],
]
]);
printf("RequestId:%s\n", $resp['RequestId']);
}catch (Obs\Common\ObsException $obsException){
printf("ExceptionCode:%s\n", $obsException->getExceptionCode());
printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
} 
