对象存储服务 OBS-设置桶策略:请求示例 4

时间:2024-10-21 15:06:41

请求示例 4

拒绝除了某个指定的 域名 和不带referer头域的外链请求以实现防盗链白名单

防盗链白名单:http://console.huaweicloud.com

示例中桶策略字段的详细说明,具体请参考桶策略参数说明

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
PUT /?policy HTTP/1.1 
Host: examplebucket.obs.cn-north-4.myhuaweicloud.com
Date: WED, 01 Jul 2015 02:34:34 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:jZiAT8Vx4azWEvPRMWi0X5BpJMA=
 
{
	"Statement": [{
		"Effect": "Deny",
		"Action": [
		"GetObject",
		"GetObjectVersion"
		],
		"Principal": {
			"ID": ["*"]
		},
		"Resource": ["examplebucket/*"],
		"Condition": {
			"StringNotLike": {
				"Referer": [
				"http://console.huaweicloud.com*",
				"${null}"
				]
			}
		}
	}]
}
support.huaweicloud.com/api-obs/obs_04_0027.html