tencent cloud

Cloud Object Storage

PUT Bucket policy

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-05-21 16:03:07

Feature Description

The PUT Bucket policy API is used to write a permission policy to a bucket. If a permission policy already exists for the bucket, the policy uploaded by this request will overwrite the existing policy. To incrementally write a policy, you can first call GET Bucket Policy to obtain the existing policy, add the new policy to it, and then call PUT Bucket Policy.

Note:
Each root account can create a maximum of 1,000 bucket ACL rules.
The length of a single policy in the Statement within the request body must not exceed 4095 bytes.

Authorization Description

In the authorization policy, set the action to cos:PutBucketPolicy. View all actions.

Request

Request Example

PUT /?policy HTTP/1.1
Host:<BucketName-APPID>.cos.<Region>.myqcloud.com
Date: date
Content-Type:application/json
Content-MD5:MD5
Authorization: Auth String
Note:
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com. Here, <BucketName-APPID> is the bucket name with the APPID suffix, for example, examplebucket-1250000000. For details, see the Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Conventions documents. <Region> is the available region of COS. For details, see the Regions and Access Domains document.
Authorization: Auth String (For details, see Request Signature).

Request Header

This API only uses common request headers. For details, see Common Request Headers.

Request Body

The following example shows granting authorization to sub-account 100000000011 under root account 100000000001, allowing access to the object list in the bucket named examplebucket-1250000000. For an introduction to the elements in an access policy, see Access Policy Language Overview. For sample authorization policies, see COS API Authorization Policy Usage Guide.
{
"Statement": [
{
"Principal": {
"qcs": [
"qcs::cam::uin/100000000001:uin/100000000011"
]
},
"Effect": "allow",
"Action": [
"name/cos:GetBucket"
],
"Resource": [
"qcs::cos:ap-guangzhou:uid/1250000000:examplebucket-1250000000/*"
]
}
],
"version": "2.0"
}

Response

Response Headers

This API only returns common response headers. For details, see Common Response Headers.

Response Body

The response body of this request is empty.

Error Codes

This API follows unified error responses and error codes. For details, see Error Codes.

Practical Case

Request

PUT /?policy HTTP/1.1
Host: examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com
Authorization:q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1484813288;32557709288&q-key-time=1484813288;32557709288&q-header-list=host&q-url-param-list=policy&q-signature=****************************************
Content-Type: application/json
Content-Length: 233

{
"Statement": [
{
"Principal": {
"qcs": [
"qcs::cam::uin/100000000001:uin/100000000001"
]
},
"Effect": "allow",
"Action": [
"name/cos:GetBucket"
],
"Resource": [
"qcs::cos:ap-guangzhou:uid/1250000000:examplebucket-1250000000/*"
]
}
],
"version": "2.0"
}

Response

HTTP/1.1 204 No Content
Content-Type: application/xml
Content-Length: 0
Connection: keep-alive
Date: Thu Jan 19 16:19:22 2017
Server: tencent-cos
x-cos-request-id: NTg4MDc2OGFfNDUyMDRlXzc3NTlf****


Ajuda e Suporte

Esta página foi útil?

comentários