-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathcdn_refresh_dirs.c
59 lines (48 loc) · 1.55 KB
/
cdn_refresh_dirs.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "../qiniu/cdn.h"
#include "debug.h"
int main(int argc, char **argv) {
Qiniu_Client client;
Qiniu_CDN_RefreshRet ret;
Qiniu_Error error;
char **p;
int i;
char *accessKey = getenv("QINIU_ACCESS_KEY");
char *secretKey = getenv("QINIU_SECRET_KEY");
Qiniu_Mac mac;
mac.accessKey = accessKey;
mac.secretKey = secretKey;
//urls to refresh
char *dirs[] = {
"http://csdk.qiniudn.com/image1/",
"http://csdk.qiniudn.com/image2/",
"http://csdk.qiniudn.com/image3/"
};
//init
Qiniu_Client_InitMacAuth(&client, 1024, &mac);
error = Qiniu_CDN_RefreshDirs(&client, &ret, dirs, 3);
if (error.code != 200) {
printf("refresh dirs error.\n");
debug_log(&client, error);
} else {
printf("refresh dirs success.\n");
printf("Code: %d\n", ret.code);
printf("Error: %s\n", ret.error);
printf("RequestId: %s\n", ret.requestId);
p = ret.invalidUrls;
for (i = 0; i < ret.invalidUrlsCount; i++) {
printf("InvalidUrl: %s\n", *p);
++p;
}
p = ret.invalidDirs;
for (i = 0; i < ret.invalidDirsCount; i++) {
printf("InvalidDir: %s\n", *p);
++p;
}
printf("UrlQuotaDay: %d\n", ret.urlQuotaDay);
printf("UrlSurplusDay: %d\n", ret.urlSurplusDay);
printf("DirQuotaDay: %d\n", ret.dirQuotaDay);
printf("DirSurplusDay: %d\n", ret.dirSurplusDay);
Qiniu_Free_CDNRefreshRet(&ret);
}
Qiniu_Client_Cleanup(&client);
}