|
4 | 4 | import com.qiniu.common.QiniuException;
|
5 | 5 | import com.qiniu.http.Client;
|
6 | 6 | import com.qiniu.http.Response;
|
7 |
| -import com.qiniu.storage.model.FetchRet; |
8 |
| -import com.qiniu.storage.model.FileInfo; |
9 |
| -import com.qiniu.storage.model.FileListing; |
| 7 | +import com.qiniu.storage.model.*; |
10 | 8 | import com.qiniu.util.*;
|
11 | 9 |
|
12 | 10 | import java.util.ArrayList;
|
@@ -98,7 +96,7 @@ public String[] buckets() throws QiniuException {
|
98 | 96 | return r.jsonToObject(String[].class);
|
99 | 97 | }
|
100 | 98 |
|
101 |
| - public void createBucket(String bucketName, String region) throws Exception { |
| 99 | + public void createBucket(String bucketName, String region) throws QiniuException { |
102 | 100 | String url = String.format("%s/mkbucketv2/%s/region/%s", configuration.rsHost(),
|
103 | 101 | UrlSafeBase64.encodeToString(bucketName), region);
|
104 | 102 | post(url, null).close();
|
@@ -233,14 +231,6 @@ public Response changeHeaders(String bucket, String key, Map<String, String> hea
|
233 | 231 | }
|
234 | 232 |
|
235 | 233 |
|
236 |
| - //存储类型 |
237 |
| - public enum StorageType { |
238 |
| - //普通存储 |
239 |
| - COMMON, |
240 |
| - //低频存储 |
241 |
| - INFREQUENCY |
242 |
| - } |
243 |
| - |
244 | 234 | /**
|
245 | 235 | * 修改文件的类型(普通存储或低频存储)
|
246 | 236 | *
|
@@ -510,6 +500,33 @@ public Response deleteAfterDays(String bucket, String key, int days) throws Qini
|
510 | 500 | return rsPost(bucket, String.format("/deleteAfterDays/%s/%d", encodedEntry(bucket, key), days), null);
|
511 | 501 | }
|
512 | 502 |
|
| 503 | + public void setBucketAcl(String bucket, AclType acl) throws QiniuException { |
| 504 | + String url = String.format("%s/private?bucket=%s&private=%s", configuration.ucHost(), bucket, acl.getType()); |
| 505 | + Response res = post(url, null); |
| 506 | + res.close(); |
| 507 | + if (!res.isOK()) { |
| 508 | + throw new QiniuException(res); |
| 509 | + } |
| 510 | + } |
| 511 | + |
| 512 | + public BucketInfo getBucketInfo(String bucket) throws QiniuException { |
| 513 | + String url = String.format("%s/v2/bucketInfo?bucket=%s", configuration.ucHost(), bucket); |
| 514 | + Response res = post(url, null); |
| 515 | + if (!res.isOK()) { |
| 516 | + res.close(); |
| 517 | + throw new QiniuException(res); |
| 518 | + } |
| 519 | + BucketInfo info = res.jsonToObject(BucketInfo.class); |
| 520 | + return info; |
| 521 | + } |
| 522 | + |
| 523 | + |
| 524 | + public void setIndexPage(String bucket, IndexPageType type) throws QiniuException { |
| 525 | + String url = String.format("%s/noIndexPage?bucket=%s&noIndexPage=%s", configuration.ucHost(), bucket, type.getType()); |
| 526 | + Response res = post(url, null); |
| 527 | + } |
| 528 | + |
| 529 | + |
513 | 530 | /*
|
514 | 531 | * 相关请求的方法列表
|
515 | 532 | * */
|
@@ -722,4 +739,5 @@ public void remove() {
|
722 | 739 | throw new UnsupportedOperationException("remove");
|
723 | 740 | }
|
724 | 741 | }
|
| 742 | + |
725 | 743 | }
|
0 commit comments