Enables Block Public Access for a bucket.
Usage notes
-
Alibaba Cloud accounts have this permission by default. To use a RAM user or STS credentials, you must have the
oss:PutBucketPublicAccessBlockpermission. For more information, see Common examples of RAM policies. -
When enabled, all existing public access permissions are ignored and no new public access permissions can be configured. When disabled, existing permissions take effect and can be configured.
Request syntax
PUT /?publicAccessBlock HTTP/1.1
Date: GMT Date
Content-Length: ContentLength
Content-Type: application/xml
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<PublicAccessBlockConfiguration>
<BlockPublicAccess>true</BlockPublicAccess>
</PublicAccessBlockConfiguration>
Request headers
This operation uses only common request headers. For more information, see Common request headers.
Request elements
|
Element |
Type |
Required |
Example |
Description |
|
PublicAccessBlockConfiguration |
Container |
Yes |
N/A |
The container for Block Public Access configurations. Parent nodes: none Child nodes: BlockPublicAccess |
|
BlockPublicAccess |
Boolean |
No |
true |
Whether to enable Block Public Access for the bucket.
|
Examples
-
Sample request
PUT /?publicAccessBlock HTTP/1.1 Date: Mon, 19 Feb 2024 08:40:17 GMT Content-Length: 148 Content-Type: application/xml Host: examplebucket.oss-cn-hangzhou.aliyuncs.com Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=content-length,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e <?xml version="1.0" encoding="UTF-8"?> <PublicAccessBlockConfiguration> <BlockPublicAccess>true</BlockPublicAccess> </PublicAccessBlockConfiguration> -
Sample success response
HTTP/1.1 200 OK x-oss-request-id: 534B371674E88A4D8906**** Date: Mon, 19 Feb 2024 08:40:17 GMT Server: AliyunOSS
OSS SDKs
The following OSS SDKs support PutBucketPublicAccessBlock:
ossutil
For information about the ossutil command that corresponds to the PutBucketPublicAccessBlock operation, see put-bucket-public-access-block.