All Products
Search
Document Center

Object Storage Service:request-payment

Last Updated:Aug 15, 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 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 Attach a custom policy to a RAM user.

  • 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 Enable pay-by-requester.

Enable pay-by-requester for a bucket

  • Command syntax

    ossutil request-payment --method put oss://bucketname payment

    The 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 Requester

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

    ossutil request-payment --method put oss://examplebucket BucketOwner

    If 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://bucketname

    In 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://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 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 LTAI4Fw2NbDUCV8zYUzA**** -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about common options, see Common options.