forked from qiniu/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCdnRefreshDirsDemo.java
More file actions
32 lines (28 loc) · 1.09 KB
/
Copy pathCdnRefreshDirsDemo.java
File metadata and controls
32 lines (28 loc) · 1.09 KB
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
27
28
29
30
31
32
package com.qiniu;
import com.qiniu.cdn.CdnManager;
import com.qiniu.cdn.CdnResult;
import com.qiniu.common.QiniuException;
import com.qiniu.util.Auth;
//https://developer.qiniu.com/kodo/sdk/java#fusion-refresh-urls
public class CdnRefreshDirsDemo {
public static void main(String args[]) {
String accessKey = "your access key";
String secretKey = "your secret key";
Auth auth = Auth.create(accessKey, secretKey);
CdnManager c = new CdnManager(auth);
//待刷新的目录列表,目录必须以 / 结尾
String[] dirs = new String[]{
"http://javasdk.qiniudn.com/gopher1/",
"http://javasdk.qiniudn.com/gopher2/",
//....
};
try {
//单次方法调用刷新的目录不可以超过10个,另外刷新目录权限需要联系技术支持开通
CdnResult.RefreshResult result = c.refreshDirs(dirs);
System.out.println(result.code);
//获取其他的回复内容
} catch (QiniuException e) {
System.err.println(e.response.toString());
}
}
}