获取对象ACL
功能说明
获取指定桶中对象的访问权限。
方法定义
1. ObsClient->getObjectAcl(array $parameter) 2. ObsClient->getObjectAclAsync(array $parameter, callable $callback)
请求参数
字段名 | 类型 | 约束 | 说明 |
|---|---|---|---|
Bucket | string | 必选 | 桶名。 |
Key | string | 必选 | 对象名。 |
VersionId | string | 可选 | 对象的版本号。 |
返回结果
字段名 | 类型 | 说明 | ||
|---|---|---|---|---|
HttpStatusCode | integer | HTTP状态码。 | ||
Reason | string | HTTP文本描述。 | ||
RequestId | string | OBS服务端返回的请求ID。 | ||
VersionId | string | 对象的版本号。 | ||
Owner | associative array | 对象的所有者。 | ||
- | ID | string | 对象所有者的DomainId。 | |
Delivered | boolean | 桶的ACL是否向桶内对象传递。 | ||
Grants | indexed array | 被授权用户权限信息列表。 | ||
- | Grantee | associative array | 被授权用户。 | |
- | ID | string | 被授权用户的DomainId,当用户类型是Group时为空。 | |
URI | string | 被授权的用户组,当用户类型是CanonicalUser时为空。 | ||
Permission | string | 被授予的权限。 | ||
代码样例
try {
$resp = $obsClient->getObjectAcl( [
'Bucket' => 'bucketname',
'Key' => 'objectkey'
] );
printf ( "RequestId:%s\n", $resp ['RequestId'] );
printf("Owner[ID]:%s\n", $resp['Owner']['ID']);
printf("Grants\n");
foreach ($resp['Grants'] as $index => $grant){
printf("Grants[%d]", $index + 1);
printf("Grantee[ID]:%s\n", $grant['Grantee']['ID']);
printf("Grantee[URI]:%s\n", $grant['Grantee']['URI']);
printf("Permission:%s\n", $grant['Permission']);
}
} catch ( Obs\Common\ObsException $obsException ) {
printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () );
printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () );
} 
