Manage public access blocking configurations for buckets using OSS SDK for Go 2.0
This topic describes how to manage public access blocking configurations for buckets by using OSS SDK for Go V2.
Notes
-
The sample code in this topic uses the region ID
cn-hangzhouof the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use an internal endpoint. For more information about the regions and endpoints supported by Object Storage Service (OSS), see OSS regions and endpoints. -
In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials (Go SDK V1).
Sample code
References
-
For the complete sample code used to manage public access blocking configurations, see Github example.
-
For more information about the API operation that you can call to enable block public access for a bucket, see PutBucketPublicAccessBlock.
-
For more information about the API operation that you can call to query public access blocking configurations for a bucket, see GetBucketPublicAccessBlock.
-
For more information about the API operation that you can call to delete public access blocking configurations for a bucket, see DeleteBucketPublicAccessBlock.