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. Use this mode to share data without incurring the request and traffic costs when your bucket is accessed.
Prerequisites
Before you begin, ensure that you have:
An OSS bucket
The
oss:PutBucketRequestPaymentpermission to enable pay-by-requester modeThe
oss:GetBucketRequestPaymentpermission to query the pay-by-requester configuration
For permission setup, see Attach a custom access policy to a RAM user.
Usage notes
The sample code uses
cn-hangzhou(China (Hangzhou)) as the example region and a public endpoint by default. To access OSS from other Alibaba Cloud products in the same region, use an internal endpoint. For endpoint mappings, see Regions and endpoints.Set the payer to
Requesterto enable pay-by-requester mode.
Sample code
References
API reference: PutBucketRequestPayment
API reference: GetBucketRequestPayment