This topic describes how to enable Block Public Access as well as query and delete the Block Public Access configurations of Object Storage Service (OSS) resources by using OSS SDK for Go V2.
Usage notes
The sample code in this topic uses the region ID
cn-hangzhou
of 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.
Sample code
References
For the complete sample code for Block Public Access for OSS resources, see Github example.
For more information about the API operation that you can call to enable Block Public Access, see PutPublicAccessBlock.
For more information about the API operation that you can call to query the Block Public Access configurations, see GetPublicAccessBlock.
For more information about the API operation that you can call to delete the Block Public Access configurations, see DeletePublicAccessBlock.