镜像回源
更新时间:2023-06-02
若您为 Bucket 配置了镜像回源,当用户访问该 Bucket 中某一 Object 时,发现该 Object 在 BOS 中并不存在,则 BOS 会立刻向预先配置好的回源地址请求该 Object,保证访问正常进行。在请求过程中,源站返回的数据会自动给到请求用户而用户对该过程无感。同时,该数据也会自动存入 BOS,提升日后该类请求的流畅性。参考镜像回源
代码示例
mirror_args = list()
mirror_args.append({
"mode": "fetch",
"sourceUrl": "<url>",
"backSourceUrl": "<url>",
"resource": "*.jpeg",
"version": "v2",
"passQueryString": False,
"storageClass": "STANDARD",
})
response = bos_client.put_bucket_mirroring(bucket_name, mirror_args=mirror_args)
__logger.debug("[Sample] put bucket mirroing response :%s", response)
response = bos_client.get_bucket_mirroring(bucket_name)
__logger.debug("[Sample] get bucket mirroing response :%s", response)
response = bos_client.delete_bucket_mirroring(bucket_name)
__logger.debug("[Sample] delete bucket mirroing response :%s", response)