Feature Overview
This API is used to add a cross-bucket replication rule to a versioning-enabled bucket. Note that the existing cross-bucket replication rule (if any) will be overwritten.
Note
To use this API, ensure that versioning is enabled for the bucket. For the API documentation of versioning, please see PUT Bucket versioning.
Objects in MAZ buckets cannot be replicated to an OAZ bucket. For example, objects in MAZ_STANDARD cannot be replicated to STANDARD.
Requests
Sample Request
PUT /?replication HTTP/1.1Host: <BucketName-APPID>.cos.<Region>.myqcloud.comDate: GMT DateContent-MD5: MD5Authorization: Auth Stringrequest body
Note
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com, where <BucketName-APPID> is the bucket name with the APPID suffix, such as examplebucket-1250000000. You can refer to the Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Rules documentation. <Region> represents the available regions for COS, which can be found in the Regions and Access Domain Names documentation.
Authorization: Auth String (For more information, see Request Signature.)
Request Header
Request Body
You can set the cross-bucket replication configuration in the request body, which includes the rule status, priority, objects to replicate, filter scope, name and region of the destination bucket, and more.
<ReplicationConfiguration><Role>qcs::cam::uin/<OwnerUin>:uin/<SubUin></Role><Rule><Status></Status><ID></ID><Prefix></Prefix><Destination><Bucket>qcs::cos:<Region>::<BucketName-APPID></Bucket><StorageClass></StorageClass></Destination><DeleteMarkerReplication><Status></Status></DeleteMarkerReplication></Rule></ReplicationConfiguration>
The content is described in details below:
Node Name (Keyword) | Parent Node | Description | Local Disk Types | Required |
ReplicationConfiguration | - | All replication configurations | Container | Required |
Role | ReplicationConfiguration | Initiator Identity Identifier: qcs::cam::uin/<OwnerUin>:uin/<SubUin> | String | Required |
Rule | ReplicationConfiguration | Specific configuration. You can set a maximum of 1,000 rules. | Container | Required |
ID | ReplicationConfiguration.Rule | Name of a specific rule | String | Not required |
Status | ReplicationConfiguration.Rule | Rule status identifier. Enumerated values: Enabled, Disabled. | String | Required |
Prefix | ReplicationConfiguration.Rule | Prefix of the object to be replicated | String | Not required |
Destination | ReplicationConfiguration.Rule | Destination bucket information | Container | Required |
Bucket | ReplicationConfiguration.Rule.Destination | Resource identifier: qcs::cos:<Region>::<BucketName-APPID> | String | Required |
DeleteMarkerReplication | ReplicationConfiguration.Rule | Whether to sync the delete marker | Container | Not required |
Status | ReplicationConfiguration.Rule. DeleteMarkerReplication | Whether to sync the delete marker. Valid values: Disabled, Enabled. Default value: Enabled. | String | Not required |
Response
Response Header
Response Body
The response body is empty.
Error Codes
Examples
Requests
The following request adds a bucket replication configuration to the
originbucket-1250000000 bucket. In this configuration, objects with the prefix testPrefix are specified for replication, and the destination bucket is destinationbucket-1250000000 in Guangzhou.PUT /?replication HTTP/1.1Date: Mon, 28 Aug 2017 02:53:38 GMTAuthorization: q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0a1ICvR<1>**&q-sign-time=1503888878;1503889238&q-key-time=1503888878;1503889238&q-header-list=host&q-url-param-list=replication&q-signature=254bf9cd3d6615e89a36ab652437f9d45c5f</1>**Content-MD5: AAq9nzrpsz5LJ4UEe1f6Q==Host: originbucket-1250000000.cos.ap-guangzhou.myqcloud.comContent-Length: 312<ReplicationConfiguration><Role>qcs::cam::uin/100000000001:uin/100000000001</Role><Rule><Status>Enabled</Status><ID>RuleId_01</ID><Prefix>testPrefix</Prefix><Destination><Bucket>qcs::cos:ap-guangzhou::destinationbucket-1250000000</Bucket></Destination></Rule></ReplicationConfiguration>
Response
After the request above is made, COS returns the following response, indicating that the cross-bucket replication rule has been successfully configured.
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 0Connection: keep-aliveDate: Fri, 14 Apr 2019 07:06:19 GMTServer: tencent-cosx-cos-bucket-region: ap-guangzhoux-cos-request-id: NWQwMzQ3NmJfMjRiMjU4NjRfOTM4NV82ZDU1****x-cos-trace-id: OGVmYzZiMmQzYjA2OWNhODk0NTRkMTBiOWVmMDAxODc0OWRkZjk0ZDM1NmI1M2E2MTRlY2MzZDhmNmI5MWI1OWE4OGMxZjNjY2JiNTBmMTVmMWY1MzAzYzkyZGQ2ZWM4MzUyZTg1NGRhNWY0NTJiOGUyNTViYzgyNzgxZTEwOTY=