All Products
Search
Document Center

Object Storage Service:put-bucket-request-payment

Last Updated:Sep 18, 2024

Enables pay-by-requester for a bucket.

Usage notes

  • By default, an Alibaba Cloud account has the permissions to enable pay-by-requester for a bucket. To enable pay-by-requester for a bucket by using a RAM user or Security Token Service (STS), you must have the oss:PutBucketRequestPayment permission. For more information, see Attach a custom policy to a RAM user.

  • If you enable pay-by-requester for a bucket, anonymous users cannot access the bucket. 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.

  • If you enable pay-by-requester for a bucket, requesters must specify the x-oss-request-payer:requester header in the POST, GET, or HEAD request. This header indicates that requesters understand that they are charged for the requests and downloaded data. Otherwise, the requests cannot be authenticated. The bucket owner does not need to specify the x-oss-request-payer header in requests that are sent to access the bucket. When the bucket owner accesses the bucket, the bucket owner is charged for the request and traffic fees.

Command syntax

ossutil api put-bucket-request-payment --bucket value --request-payment-configuration value [flags]

Parameter

Type

Description

--bucket

string

The name of the bucket.

--request-payment-configuration

string

The container that stores pay-by-requester configurations.

Note

The put-bucket-request-payment command corresponds to the PutBucketRequestPayment operation. For more information about the parameters in the PutBucketRequestPayment operation, see PutBucketRequestPayment.

--request-payment-configuration

The --request-payment-configuration configuration option supports both the XML and JSON formats. If the value of the option contains the file:// prefix, the configurations are read from a configuration file.

  • XML format:

    <RequestPaymentConfiguration>
      <Payer>string</Payer>
    </RequestPaymentConfiguration>
  • JSON format:

    {
      "Payer": "string"
    }
Note

For more information about supported global command-line options, see Global command-line options.

Examples

The following example shows how to enable pay-by-requester for a bucket named examplebucket.

  • Create a configuration file named request-payment-configuration.xml and add the following code to the configuration file:

    <?xml version="1.0" encoding="UTF-8"?>
    <RequestPaymentConfiguration>
      <Payer>Requester</Payer>
    </RequestPaymentConfiguration>

    Sample command:

    ossutil api put-bucket-request-payment --bucket examplebucket --request-payment-configuration file://request-payment-configuration.xml
  • Create a configuration file named request-payment-configuration.json and add the following code to the configuration file:

    {
      "Payer": "Requester"
    }

    Sample command:

    ossutil api put-bucket-request-payment --bucket examplebucket --request-payment-configuration file://request-payment-configuration.json
  • Configure parameters in the following command in the JSON format:

    ossutil api put-bucket-request-payment --bucket examplebucket --request-payment-configuration "{\"Payer\":\"Requester\"}"