Manage bucket policies using OSS SDK for PHP 2.0
A bucket policy allows you to authorize or restrict access of anonymous users or identified users, such as Alibaba Cloud accounts, RAM users, and RAM roles, to specific Object Storage Service (OSS) resources. For example, you can grant read-only permissions on specific OSS resources to a RAM user of another Alibaba Cloud account.
Usage notes
-
Before you configure bucket policies, make sure that you are familiar with this feature. For more information, see Bucket Policy.
-
The sample code in this topic uses the region ID
cn-hangzhouof the China (Hangzhou) region. By default, a 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 OSS regions and endpoints, see Regions and endpoints. -
To configure a bucket policy, you must have the
oss:PutBucketPolicypermission. To query bucket policies, you must have theoss:GetBucketPolicypermission. To delete a bucket policy, you must have theoss:DeleteBucketPolicypermission. For more information, see Grant a custom policy.
Examples
References
-
For the complete sample code that is used to configure a bucket policy, visit GitHub.
-
For more information about the API operation that you can call to configure a bucket policy, see PutBucketPolicy.
-
For the complete sample code that is used to query bucket policies, visit GitHub.
-
For more information about the API operation that you can call to query bucket policies, see GetBucketPolicy.
-
For the complete sample code that is used to delete a bucket policy, visit GitHub.
-
For more information about the API operation that you can call to delete a bucket policy, see DeleteBucketPolicy.