Put Bucket ACL

Last Updated: Mar 20, 2017

The Put Bucket ACL interface is used to modify the access permissions for a bucket. Currently, three bucket access permissions are available: public-read-write, public-read, and private. You can use the “x-oss-acl” header in a Put request to set the Put Bucket ACL operation. Only the creator of the bucket has permission to perform this operation. If the operation succeeds, 200 will be returned; otherwise, the corresponding error code and prompt message will be returned.

Request syntax

  1. PUT /?acl HTTP/1.1
  2. x-oss-acl: Permission
  3. Host: BucketName.oss-cn-hangzhou.aliyuncs.com
  4. Date: GMT Date
  5. Authorization: SignatureValue

Detail analysis

  1. When a bucket already exists and is owned by the request sender and the permission in the request is different from the existing permission, this request does not change bucket content but updates permission.
  2. If the information for user authentication is not introduced when you initiate a Put Bucket request, the message of 403 Forbidden will be returned. Error code: AccessDenied.
  3. If the “x-oss-acl” header is unavailable in a request and the bucket already exists and belongs to the request sender, the permissions for the original bucket remain the same.

Example

Request example:

  1. PUT /?acl HTTP/1.1
  2. x-oss-acl: public-read
  3. Host: oss-example.oss-cn-hangzhou.aliyuncs.com
  4. Date: Fri, 24 Feb 2012 03:21:12 GMT
  5. Authorization: OSS qn6qrrqxo2oawuk53otfjbyc:KU5h8YMUC78M30dXqf3JxrTZHiA=

Response example:

  1. HTTP/1.1 200 OK
  2. x-oss-request-id: 534B371674E88A4D8906008B
  3. Date: Fri, 24 Feb 2012 03:21:12 GMT
  4. Content-Length: 0
  5. Connection: keep-alive
  6. Server: AliyunOSS

If the permission for this setting does not exist, the message of 400 Bad Request is shown:

Returned error example:

  1. HTTP/1.1 400 Bad Request
  2. x-oss-request-id: 56594298207FB304438516F9
  3. Date: Fri, 24 Feb 2012 03:55:00 GMT
  4. Content-Length: 309
  5. Content-Type: text/xml; charset=UTF-8
  6. Connection: keep-alive
  7. Server: AliyunOSS
  8. <?xml version="1.0" encoding="UTF-8"?>
  9. <Error>
  10. <Code>InvalidArgument</Code>
  11. <Message>no such bucket access control exists</Message>
  12. <RequestId>56594298207FB304438516F9</RequestId>
  13. <HostId>leo.oss-test.aliyun-inc.com</HostId>
  14. <ArgumentName>x-oss-acl</ArgumentName>
  15. <ArgumentValue>error-acl</ArgumentValue>
  16. </Error>
Thank you! We've received your feedback.