You can call this operation to enable pay-by-requester for a bucket.
Note the following items when you enable pay-by-requester for a bucket:
- Access from anonymous users is rejected
If you enable pay-by-requester for a bucket, anonymous users are not allowed to access the bucket. Requesters must provide authentication information to OSS so that OSS can identify and charge requesters for requests and traffic.
If a requester assumes a RAM role of an Alibaba Cloud account to request data, OSS charges this Alibaba Cloud account for the requests sent by the requester and the generated traffic.
- Requesters must specify the x-oss-request-payer header in the request
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 requests. This header indicates that requesters understand that they are charged for the requests and downloaded data. If requester does not specify the x-oss-request-payer header in requests sent to a bucket with pay-by-requester enabled, the requests fail to pass authentication.
Bucket owners do not need to specify the x-oss-request-payer header in requests sent to access their buckets. In this case, bucket owners are charged for the requests sent by them and the traffic generated by the requests.
PUT /? requestPayment HTTP/1.1 Date: GMT Date Content-Length: ContentLength Content-Type: application/xml Host: BucketName.oss.aliyuncs.com Authorization: SignatureValue <? xml version="1.0" encoding="UTF-8"? > <RequestPaymentConfiguration> <Payer>Requester</Payer> </RequestPaymentConfiguration>
PutBucketRequestPayment requests contain only common request headers. For more information, see Common request headers.
|RequestPaymentConfiguration||Container||Yes||The container that stores pay-by-requester configurations.
Child node: Payer
|Payer||String||Yes||The payer of the request and traffic fees.
Parent node: RequestPaymentConfiguration
Responses for PutBucketRequestPayment requests contain only common response headers. For more information, see Common response headers.
PUT /? requestPayment Content-Length: 83 Host: oss-example.oss-cn-hangzhou.aliyuncs.com Date: Tue, 23 Jul 2019 01:33:47 GMT Authorization: OSS qn6qrrqxo2oawuk53otf****:77Dvh5wQgIjWjwO/KyRt8dOP**** <RequestPaymentConfiguration> <Payer>Requester</Payer> </RequestPaymentConfiguration>
200 (OK) content-length: 0 x-oss-request-id: 5D3663FBB007B79097FC**** date: Tue, 23 Jul 2019 01:33:47 GMT
|Error code||HTTP status code||Description|
|NoSuchBucket||404||The error message returned because the specified bucket does not exist.|