All Products
Search
Document Center

Object Storage Service:request-payment

Last Updated:Apr 03, 2024

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 configure pay-by-requester settings for a bucket, you must have the oss:PutBucketRequestPayment permission. To query the pay-by-requester settings of a bucket, you must have the oss:GetBucketRequestPayment permission. For more information, see Attach a custom policy to a RAM user.

  • This topic provides sample command lines that are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil command reference.

  • For more information about pay-by-requester, see Enable pay-by-requester.

Configure pay-by-requester settings for a bucket

  • Command syntax

    ./ossutil64 request-payment --method put oss://bucketname payment

    The following table describes the parameters in the syntax.

    Parameter

    Description

    bucketname

    The name of the bucket for which you want to configure pay-by-requester settings.

    payment

    The payment method for the fees that are incurred when third-party users access data in the bucket.

    Valid values:

    • Requester: Requesters are charged the fees that are incurred 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 when requesters access objects in the bucket.

  • Examples

    You can run the following command to enable pay-by-requester for a bucket named examplebucket:

    ./ossutil64 request-payment --method put oss://examplebucket Requester

    You can run the following command to disable pay-by-requester for a bucket named examplebucket:

    ./ossutil64 request-payment --method put oss://examplebucket BucketOwner

    The following sample output indicates that pay-by-requester setting is complete:

    0.106852(s) elapsed

Query the pay-by-requester settings of a bucket

  • Command syntax

    ./ossutil64 request-payment --method get oss://bucketname

    In the syntax, bucketname specifies the bucket of which you want to query the pay-by-requester settings.

  • Examples

    You can run the following command to query the pay-by-requester settings of a bucket named examplebucket:

    ./ossutil64 request-payment --method get oss://examplebucket

    The following sample output indicates that pay-by-requester is enabled for the bucket:

    Requester
    0.072024(s) elapsed

Common options

If you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account.

For example, you can run the following command to configure pay-by-requester settings for a bucket named testbucket that is located in the China (Shanghai) region and owned by another Alibaba Cloud account:

./ossutil64 request-payment --method put oss://testbucket -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA**** -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about other common options that you can use for the sync command, see Common options.