In pay-by-requester mode, the requester pays for the traffic and request fees generated when data is read from a bucket, while the bucket owner pays only for storage fees. You can enable this feature for a bucket to share data without incurring charges for the requests and traffic generated when your bucket is accessed.
Usage notes
The sample code in this topic uses the region ID
cn-hangzhoufor the China (Hangzhou) region as an example. By default, a public endpoint is used. If you want to access OSS from other Alibaba Cloud products in the same region, use an internal endpoint. For more information about the mappings between OSS regions and endpoints, see Regions and endpoints.To set the pay-by-requester mode, you must have the
oss:PutBucketRequestPaymentpermission. To query the pay-by-requester mode, you must have theoss:GetBucketRequestPaymentpermission. For more information, see Attach a custom access policy to a RAM user.
Sample code
References
For the complete sample code for setting the pay-by-requester mode, see GitHub sample.
For more information about the API operation for setting the pay-by-requester mode, see PutBucketRequestPayment.
For the complete sample code for querying the pay-by-requester configuration, see GitHub sample.
For more information about the API operation for querying the pay-by-requester configuration, see GetBucketRequestPayment.