All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Put Bucket Policy

Last updated:2021-09-23 15:02:41

Description

This PUT interface can add a BucketPolicy to a bucket. If an interface already has a BucketPolicy, the newly added BucketPolicy will completely replace the old one. If you want to use this interface, you need to be the owner of this Bucket. If the interface call succeeds, 204 will be returned. If the call fails, the error code and specific error information will be returned.

Request

Grammar

PUT /?policy HTTP/1.1
Host: {BucketName}.{endpoint}
Date: {date}
Authorization: {SignatureValue}
Policy written in JSON

Note:

Request parameters

The interface does not use request parameters.

Request header

This interface only uses common request headers. For more information, please click Public request headers.

Request content

A JSON string describing the bucket policy.

Response header

This interface can use all common response headers. For more information, please click Public response headers.

Response content

The interface does not return the corresponding content.

Special errors

The interface does not return any special errors.

Example

Request example

PUT /?policy HTTP/1.1
Host: ks3-example.ks3-cn-beijing.ksyuncs.com
Content-Length: 225
Authorization: authorization string
Content-Md5: 8evRehlmPHkf+VuSe8k6Rg==
Date: Tue, 19 Jul 2016 09:12:54 GMT

{
    "Version":"2008-10-17",
    "Statement":[
        {
            "Sid":"1",
            "Effect":"Allow",
            "Principal":{
                "KSC":[
                    "krn:ksc:iam::accountID:root",
                    "krn:ksc:iam::accountID:user/userName"
                ]
            },
            "Action":[
                "ks3:*"
            ],
            "Resource":[
                "krn:ksc:ks3:::ks3-example",
                "krn:ksc:ks3:::ks3-example/*"
            ],
            "Condition":{
                "IpAddress":{
                    "ksc:SourceIp":"54.240.143.1"
                }
            }
        }
    ]
}

Response example

HTTP/1.1 204 No Content
Content-Length: 0
Connection: keep-alive
Date: Tue, 19 Jul 2016 09:14:23 GMT
Server: Tengine
X-Application-Context: application
X-Kss-Request-Id: 54a47bda18ac4e6e91de369add54218e
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback