When pay-by-requester is enabled for a bucket, requesters pay the request and traffic fees that are incurred when the requesters access objects in the bucket. The bucket owner must still pay the storage fees of the objects in the bucket. If you want to share your data without having to pay for requests made by others, you can use the request-payment command to enable pay-by-requester for your bucket.
Usage notes
-
To enable pay-by-requester for a bucket, you must have the oss:PutBucketRequestPayment permission. To query the pay-by-requester configurations of a bucket, you must have the oss:GetBucketRequestPayment permission. For more information, see Grant a custom policy.
-
For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.
-
For more information about pay-by-requester, see Pay-by-requester.
Enable pay-by-requester for a bucket
-
Command syntax
ossutil request-payment --method put oss://bucketname paymentThe following table describes the preceding parameters.
Parameter
Description
bucketname
The name of the bucket for which you want to enable pay-by-requester.
payment
The payment method for the fees that are generated when third-party users access data in the bucket.
Valid values:
-
Requester: Requesters are charged the fees that are generated to access objects in the bucket.
Anonymous users cannot access a bucket that has pay-by-requester enabled. Requesters must provide authentication information. OSS can identify requesters based on the given information. This way, the requesters are charged request and traffic fees. If a requester uses a RAM user of an Alibaba Cloud account to request data, the Alibaba Cloud account to which the RAM user belongs is charged for the requests sent by the requester and the generated traffic.
-
BucketOwner: The bucket owner is charged the fees that are generated when requesters access objects in the bucket.
-
-
Examples
You can run the following command to enable pay-by-requester for a bucket named examplebucket:
ossutil request-payment --method put oss://examplebucket RequesterYou can run the following command to disable pay-by-requester for a bucket named examplebucket:
ossutil request-payment --method put oss://examplebucket BucketOwnerIf a similar output is displayed, pay-by-requester is enabled or disabled for the bucket.
0.106852(s) elapsed
Query the pay-by-requester configurations of a bucket
-
Command syntax
ossutil request-payment --method get oss://bucketnameIn the syntax, bucketname specifies the bucket of which you want to query the pay-by-requester configurations.
-
Examples
You can run the following command to query the pay-by-requester configurations of a bucket named examplebucket:
ossutil request-payment --method get oss://examplebucketThe following sample output indicates that pay-by-requester is enabled for the bucket:
Requester 0.072024(s) elapsed
Common options
To access a bucket in a different region, use -e to specify the endpoint. To access a bucket owned by a different Alibaba Cloud account, use -i for the AccessKey ID and -k for the AccessKey secret.
For example, you can run the following command to enable pay-by-requester for a bucket named testbucket that is located in the China (Shanghai) region and owned by another Alibaba Cloud account:
ossutil request-payment --method put oss://testbucket -e oss-cn-shanghai.aliyuncs.com -i yourAccessKeyID -k yourAccessKeySecret