All Products
Search
Document Center

Object Storage Service:PutBucketPolicy

Last Updated:Feb 27, 2025

You can call PutBucketPolicy to configure policies for a specified bucket.

Request syntax

PUT /?policy
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
Policy written in JSON

Request headers

All headers in a PutBucketPolicy request are common request headers. For more information, see Common request headers.

Response headers

All headers in the response to a PutBucketPolicy request are common response headers. For more information, see Common response headers.

Examples

  • Sample requests

    PUT /?policy
    Content-Length: 230
    Host: oss-example.oss-cn-hangzhou.aliyuncs.com
    Date: Thu, 21 Feb 2019 12:51:09 GMT
    Authorization: OSS qn6q**************:77Dv****************
    {
       "Version":"1",
       "Statement":[
       {
         "Action":[
           "oss:PutObject",
           "oss:GetObject"
        ],
        "Effect":"Deny",
        "Principal":["1234567890"],
        "Resource":["acs:oss:*:1234567890:*/*"]
       }
      ]
     }
  • Sample responses

    HTTP/1.1 200 OK
    content-length: 0
    server: AliyunOSS
    x-oss-server-time: 87
    connection: keep-alive
    x-oss-request-id: 5C6E9EBD5CC26B28EE41****
    date: Thu, 21 Feb 2019 12:51:09 GMT

OSS SDK

You can use OSS SDKs for the following programming languages to call the PutBucketPolicy operation: