PutBucketACL
PutBucketACL接口用于修改Bucket访问权限。目前Bucket有两种种访问权限:public-read和private。PutBucketACL操作通过Put请求中的“x-cos-acl”头来设置。这个操作只有该Bucket的创建者有权限执行。如果操作成功,则返回200;否则返回相应的错误码和提示信息。
请求语法
PUT /?acl HTTP/1.1
x-cos-acl: public-read
Host: bucketname.cos.chinac.com
Date: GMT Date
Authorization: SignatureValue
细节分析
- 如果bucket存在,发送时带的权限和已有权限不一样,并且请求发送者是bucket拥有者时。该请求不会改变bucket内容,但是会更新权限
- 如果用户发起PutBucketACL请求的时候,没有传入用户验证信息,返回403 Forbidden消息。错误码:AccessDenied
- 如果请求中没有“x-cos-acl”头,并且该bucket已存在,并属于该请求发起者,则维持原bucket权限不变
示例
请求示例
PUT /?acl HTTP/1.1
x-cos-acl: public-read
Host: test-bucket.cos.chinac.com
Date: Fri, 24 Feb 2012 03:21:12 GMT
Authorization: COS qn6qrrqxo2oawuk53otfjbyc:KU5h8YMUC78M30dXqf3JxrTZHiA=
正确返回示例
HTTP/1.1 200 OK
x-cos-request-id: 534B371674E88A4D8906008B
Date: Fri, 24 Feb 2012 03:21:12 GMT
Content-Length: 0
Connection: keep-alive
Server: COS
错误返回示例
HTTP/1.1 400 Bad Request
x-cos-request-id: 56594298207FB304438516F9
Date: Fri, 24 Feb 2012 03:55:00 GMT
Content-Length: 309
Content-Type: application/json
Connection: keep-alive
Server: COS
{
"Code": "InvalidArgument",
"Message": "参数“x-cos-acl=public-write”无效,有效值为:private,public-read",
"Resource": "",
"RequestId": "72038d78ac1000000153171756a5091b"
}