Bucket policies let you grant or deny fine-grained access to specific Object Storage Service (OSS) resources for authenticated users, such as Alibaba Cloud accounts, Resource Access Management (RAM) users, and RAM roles, or for anonymous users. For example, you can grant a RAM user from another Alibaba Cloud account read-only access to specified OSS resources.
Precautions
Setting a bucket policy requires the oss:PutBucketPolicy permission. Retrieving a bucket policy requires the oss:GetBucketPolicy permission. Deleting a bucket policy requires the oss:DeleteBucketPolicy permission. For more information, see Grant custom access policies to a RAM user.
Sample code
References
-
For the complete sample code for setting a bucket policy, see GitHub.
-
For the complete sample code for retrieving a bucket policy, see GitHub.
-
For the complete sample code for deleting a bucket policy, see GitHub.
-
For more information about the API operation for setting a bucket policy, see PutBucketPolicy.
-
For more information about the API operation for retrieving a bucket policy, see GetBucketPolicy.
-
For more information about the API operation for deleting a bucket policy, see DeleteBucketPolicy.