You can use OSS SDK for Go V2 to enable Block Public Access for Object Storage Service (OSS) resources, and query or delete the Block Public Access configurations.
Usage notes
-
The sample code uses the region ID
cn-hangzhouof the China (Hangzhou) region and the public endpoint by default. To access resources by using other Alibaba Cloud services in the same region as the bucket, use an internal endpoint. For more information about the regions and endpoints supported by Object Storage Service (OSS), see OSS regions and endpoints. -
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, see Github example.
-
For the API operation to enable Block Public Access, see PutPublicAccessBlock.
-
For the API operation to query the Block Public Access configurations, see GetPublicAccessBlock.
-
For the API operation to delete the Block Public Access configurations, see DeletePublicAccessBlock.