原图保护
更新时间:2026-09-23
put_bucket_copyright_protection
本接口用来开启 Bucket 的原图保护功能,并指定 resource 字段,表示生效的资源范围。对于开通原图保护的文件,不允许匿名下载访问该文件,或带自定义图片处理参数访问,只允许使用 style 样式访问或携带合法签名访问。
运行以下示例前,请先参考初始化完成 BOS Client 初始化,并将示例中的 bucket_name(及其它占位符)替换为实际值。
Python
1resource = [bucket_name + "/test/*"]
2response = bos_client.put_bucket_copyright_protection(bucket_name, resource)
返回值说明如下:
| 返回值 | 类型 | 说明 |
|---|---|---|
response |
BceResponse |
SDK 返回的通用响应对象,可通过 response.status_code 查看 HTTP 状态码,通过 response.metadata 查看响应头元数据。 |
参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket_name |
str |
是 | Bucket 名称。 |
resource |
list |
是 | 原图保护生效的资源范围。每个元素为字符串,例如 bucket_name + "/test/*"。 |
get_bucket_copyright_protection
此命令用来获取某个 Bucket 的原图保护配置情况。
Python
1response = bos_client.get_bucket_copyright_protection(bucket_name)
返回值说明如下:
| 返回值 | 类型 | 说明 |
|---|---|---|
response |
BceResponse |
SDK 返回的通用响应对象,可通过 response.status_code 查看 HTTP 状态码,通过 response.metadata 查看响应头元数据。 |
参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket_name |
str |
是 | Bucket 名称。 |
delete_bucket_copyright_protection
本接口用来关闭 Bucket 原图保护功能。
Python
1response = bos_client.delete_bucket_copyright_protection(bucket_name)
返回值说明如下:
| 返回值 | 类型 | 说明 |
|---|---|---|
response |
BceResponse |
SDK 返回的通用响应对象,可通过 response.status_code 查看 HTTP 状态码,通过 response.metadata 查看响应头元数据。 |
参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket_name |
str |
是 | Bucket 名称。 |
评价此篇文章
