Mirror back-to-origin
Updated at:2025-11-03
If you configured mirror back-to-origin for the bucket, when you access an object in the bucket that does not exist in BOS, BOS will immediately request the object from the pre-configured back-to-origin address to ensure normal access. During the request process, the data returned by the origin server is automatically delivered to the requesting user without their awareness. Meanwhile, this data will also be automatically stored in BOS, improving the smoothness of such requests in the future. Refer to Mirror Back-To-Origin.
2. When a user performs an overwrite operation, the old data will not enter the bucket trash
| Parameters | Description |
|---|---|
| bucketName | The requested bucket name |
| bucketMirroringConfigurations | Enable bucket trash (PutBucketTrash) |
Specify the name of the bucket trash directory.
Java
1If not filled in, the default bucket trash directory is ".trash"
2BucketMirroringConfiguration config = BucketMirroringConfiguration.builder()
3 .mode("fetch")
4 .sourceUrl("http://xxx.bj.bcebos.com")
5 .resource("*")
6 .build();
7List<BucketMirroringConfiguration> bucketMirroringConfigurations =
8 new ArrayList<BucketMirroringConfiguration>();
9bucketMirroringConfigurations.add(config);
10 // Request
11this.client.putBucketMirroring(bucketName, bucketMirroringConfigurations);
Note:
Java
1If not filled in, the default bucket trash directory is ".trash"
2String configJson = "{\"bucketMirroringConfiguration\":[{\"mode\":\"fetch\"," +
3 "\"sourceUrl\":\"http://xxx.bj.bcebos.com\",\"resource\":\"*\",\"prefix\":\"\"," +
4 "\"suffix\":\"\"," +
5 "\"fixedKey\":\"\",\"version\":\"v1\",\"customHeaders\":[],\"storageClass\":\"STANDARD\"," +
6 "\"ignoreHeaders\":[],\"passHeaders\":[]}]}";
7
8 // Request
9this.client.putBucketMirroring(bucketName, configJson);
1. If the bucket trash function has been enabled before, re-enabling it will overwrite the original bucket trash directory name;
| Parameters | Description |
|---|---|
| bucketName | The requested bucket name |
Code example
Java
1// Request
2GetBucketMirroringResponse response = this.client.getBucketMirroring(bucketName);
3System.out.println(response.getBucketMirroringConfiguration().toString());
2. The name of the bucket trash directory can only contain letters, numbers, Chinese characters, underscores (_), hyphens (-), and decimal points (.).
| Parameters | Description |
|---|---|
| bucketName | The requested bucket name |
Code example
Java
1this.client.deleteBucketMirroring(bucketName);
