PutBucketReplication
Updated at:2025-11-03
API description
This API is used to set up data synchronization. Each ID uniquely identifies a replication rule. The first submission for an ID creates a replication rule, while subsequent submissions overwrite it. If the original status is "enable," overwriting it to "disable" is not permitted. If the original status is "enable," resubmitting it as "enable" will restart the replication. Two replication rules cannot have identical configurations except for their IDs.
Description:
- The user must own the source bucket with FULL_CONTROL permission and have write access to the target bucket.
- Both the source bucket and the target bucket must exist.
- The source bucket and target bucket can be in the same region or different regions.
- The target bucket and source bucket can be under the same account or different accounts, but the source account must have the write permission for the destination bucket.
- The total configuration size must not exceed 128 KB, and the combined length of all rules under the current bucket must not exceed 200 KB.
- Data synchronization does not currently support archive storage class files; such files will be ignored during the synchronization process.
- Users can configure up to 10 replication rules.
- A single rule can include up to 20 resources.
- A single rule can include up to 20 notIncludeResource items.
- The ID must consist of numbers, letters, hyphens (-), and underscores (_), and shall not exceed 20 characters
Request
-
Request syntax
Plain Text1PUT /?replication&id=sample-bucket HTTP/1.1 2Host: <BucketName>.bj.bcebos.com 3x-bce-date: date 4Content-Length: request-body length 5Content-Type: application/json; charset=utf-8 6Authorization:<AuthorizationString> 7{ 8 "status": "enabled", 9 "resource": [ 10 "src-bucket-name/abc", 11 "src-bucket-name/cd*" 12 ], 13 "notIncludeResource": [ 14 src-bucket-name/prefix/*, 15 src-bucket-name/*.jpeg, 16 src-bucket-name/*test* 17 ], 18 "destination": { 19 "bucket": "dst-bucket-name", 20 "storageClass": "COLD" 21 }, 22 "replicateHistory": { 23 "storageClass": "COLD" 24 }, 25 "replicateDeletes": "enabled", 26 "id": "sample-bucket" 27} -
Request headers
No special parameters
-
Request parameters
| Parameters | Required or not | Description |
|---|---|---|
| id | Yes | Rule name of replication. The ID must consist of numbers, letters, hyphens (-), and underscores (_), and shall not exceed 20 characters. |
| status | Yes | Is it effective |
| resource | Yes | Effective prefix of replication. The resource configuration format is {$bucket_name/$bucket_name+/. |
| notIncludeResource | No | The non-effective scope of replication. The notIncludeResource configuration format is {$bucket_name/$bucket_name+/, and only be in the following three formats: ${bucketname}/*,${bucketname}/*+* +Non-effective Object Infix + *. Refer to the request example for details. |
| destination | Yes | Destination location configuration of replication |
| +bucket | Yes | Destination bucket name: For cross-region synchronization, the system will automatically retrieve the region information based on the bucket name. |
| +storageClass | No | Storage class of destination object. If the storage class is to be consistent with that of the source Bucket, this parameter does not need to be configured; if you need to specify a separate storage class, it can be STANDARD, STANDARD_IA and COLD; if it is a multi-AZ type bucket, the available values are MAZ_STANDARD_IA and MAZ_STANDARD. |
| +prefix | No | Destination storage path |
| replicateHistory | No | Historical file replication: When enabled, all existing objects will be synchronously replicated to the destination bucket, sharing the same resource scope. |
| +storageClass | No | Storage class of destination object. If the storage class is to be consistent with that of the source Bucket, this parameter does not need to be configured; if you need to specify a separate storage class, it can be STANDARD, STANDARD_IA and COLD; if it is a multi-AZ type bucket, the available values are MAZ_STANDARD_IA and MAZ_STANDARD. |
| replicateDeletes | Yes | It indicates whether Delete synchronization function is enabled. It is enabled or disabled. |
Response
Example
-
Request example
Plain Text1 PUT /?replication&id=sample-bucket HTTP/1.1 2 Host: BucketName.bj.bcebos.com 3 x-bce-date: date 4 Content-Length: xxx 5 Content-Type: application/json; charset=utf-8 6 Authorization: AuthorizationString 7 { 8 "status": "enabled", 9 "resource": [ 10 "src-bucket-name/abc", 11 "src-bucket-name/cd*" 12 ], 13 "notIncludeResource": [ 14 src-bucket-name/prefix/*, 15 src-bucket-name/*.jpeg, 16 src-bucket-name/*test* 17 ], 18 "destination": { 19 "bucket": "dst-bucket-name", 20 "storageClass": "COLD", 21 "prefix": "dst-file-name/" 22 }, 23 "replicateHistory": { 24 "storageClass": "COLD" 25 }, 26 "replicateDeletes": "enabled", 27 "id": "sample-bucket-replication-config" 28 } -
Response example
Plain Text1 HTTP/1.1 200 OK 2 x-bce-request-id: xxxx-xxxx-xxxx 3 Date: Wed, 12 May 2017 17:50:00 GMT 4 Content-Length: 0 5 Connection: keep-alive 6 Server: BceBos
