Skip to content

Commit 89e8dce

Browse files
author
YangSen-qn
committed
format
1 parent 9d260cb commit 89e8dce

File tree

146 files changed

+2800
-2676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2800
-2676
lines changed

CHANGELOG.md

Lines changed: 107 additions & 10 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
# Qiniu Resource Storage SDK for Java
2+
23
[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
34
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
45
[![Build Status](https://travis-ci.org/qiniu/java-sdk.svg)](https://travis-ci.org/qiniu/java-sdk)
56
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/java-sdk.svg?label=release)](https://github.com/qiniu/java-sdk/releases)
67
[![Docs](https://img.shields.io/github/v/tag/qiniu/java-sdk.svg?label=docs&color=yellow)](https://qiniu.github.io/java-sdk/)
78
[![Coverage Status](https://codecov.io/gh/qiniu/java-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/java-sdk)
89
[![Latest Stable Version](https://img.shields.io/maven-central/v/com.qiniu/qiniu-java-sdk.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.qiniu%22%20AND%20a%3A%22qiniu-java-sdk%22)
10+
911
## 安装
1012

1113
下载 [the latest JAR][1] 或者 通过 Maven:
14+
1215
```xml
1316
<dependency>
1417
<groupId>com.qiniu</groupId>
1518
<artifactId>qiniu-java-sdk</artifactId>
1619
<version>[7.15.0, 7.15.99]</version>
1720
</dependency>
1821
```
22+
1923
或者 Gradle:
24+
2025
```groovy
2126
implementation 'com.qiniu:qiniu-java-sdk:7.15.+'
2227
```
@@ -28,6 +33,7 @@ JDK 7 及以上
2833
## 使用方法
2934

3035
### 上传
36+
3137
```Java
3238
// 分片上传 v1
3339
import com.qiniu.storage.UploadManager;
@@ -73,6 +79,7 @@ $ ./gradlew build
7379
```
7480

7581
## 生成Eclipse工程文件
82+
7683
``` bash
7784
$ ./gradlew gen_eclipse
7885
```
@@ -105,6 +112,9 @@ $ ./gradlew gen_eclipse
105112
The MIT License (MIT).详情见 [License文件](https://github.com/qiniu/java-sdk/blob/master/LICENSE).
106113

107114
[1]: https://search.maven.org/remote_content?g=com.qiniu&a=qiniu-java-sdk&v=LATEST
115+
108116
[2]: https://github.com/Nextpeer/okhttp
117+
109118
[3]: https://raw.githubusercontent.com/qiniu/java-sdk/master/libs/okhttp-2.3.0-SNAPSHOT.jar
119+
110120
[4]: https://raw.githubusercontent.com/qiniu/java-sdk/master/libs/okio-1.3.0-SNAPSHOT.jar

build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ task getHomeDir {
5151
apply plugin: 'checkstyle'
5252

5353
task apiJavadocs(type: Javadoc) {
54-
source = sourceSets.main.allJava
55-
classpath = sourceSets.main.runtimeClasspath
56-
title = "七牛 Java SDK API 文档"
57-
options {
58-
memberLevel = JavadocMemberLevel.PUBLIC
59-
setEncoding 'UTF-8'
60-
setWindowTitle "七牛 Java SDK API 文档"
61-
}
54+
source = sourceSets.main.allJava
55+
classpath = sourceSets.main.runtimeClasspath
56+
title = "七牛 Java SDK API 文档"
57+
options {
58+
memberLevel = JavadocMemberLevel.PUBLIC
59+
setEncoding 'UTF-8'
60+
setWindowTitle "七牛 Java SDK API 文档"
61+
}
6262
}
6363

6464
def versionName() {

codecov.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ codecov:
33
- prow.qiniu.io # prow 里面运行需添加,其他 CI 不要
44
require_ci_to_pass: no # 改为 no,否则 codecov 会等待其他 GitHub 上所有 CI 通过才会留言。
55

6-
github_checks: #关闭github checks
6+
github_checks: #关闭github checks
77
annotations: false
88

99
comment:
@@ -12,13 +12,13 @@ comment:
1212
require_changes: false # if true: only post the comment if coverage changes
1313
require_base: no # [yes :: must have a base report to post]
1414
require_head: yes # [yes :: must have a head report to post]
15-
branches: # branch names that can post comment
15+
branches: # branch names that can post comment
1616
- "master"
1717

1818
coverage:
19-
status: # 评判 pr 通过的标准
19+
status: # 评判 pr 通过的标准
2020
patch: off
21-
project: # project 统计所有代码x
21+
project: # project 统计所有代码x
2222
default:
2323
# basic
2424
target: 60% # 总体通过标准

config/checkstyle/checkstyle.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828

2929

3030
<module name="TreeWalker">
31-
<module name="SuppressionCommentFilter" />
31+
<module name="SuppressionCommentFilter"/>
3232
<!-- Checks for Javadoc comments. -->
3333
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
3434
<!--module name="JavadocMethod"/-->
3535
<!--module name="JavadocType"/-->
3636
<!--module name="JavadocVariable"/-->
3737
<module name="JavadocStyle">
38-
<property name="checkFirstSentence" value="false" />
38+
<property name="checkFirstSentence" value="false"/>
3939
</module>
4040

4141

examples/CdnRefreshDirsDemo.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
//https://developer.qiniu.com/kodo/sdk/java#fusion-refresh-urls
99

1010
public class CdnRefreshDirsDemo {
11-
public static void main(String args[]) {
12-
String accessKey = "your access key";
13-
String secretKey = "your secret key";
14-
Auth auth = Auth.create(accessKey, secretKey);
15-
CdnManager c = new CdnManager(auth);
16-
//待刷新的目录列表,目录必须以 / 结尾
17-
String[] dirs = new String[]{
18-
"http://javasdk.qiniudn.com/gopher1/",
19-
"http://javasdk.qiniudn.com/gopher2/",
20-
//....
21-
};
22-
try {
23-
//单次方法调用刷新的目录不可以超过10个,另外刷新目录权限需要联系技术支持开通
24-
CdnResult.RefreshResult result = c.refreshDirs(dirs);
25-
System.out.println(result.code);
26-
//获取其他的回复内容
27-
} catch (QiniuException e) {
28-
System.err.println(e.response.toString());
29-
}
30-
}
11+
public static void main(String args[]) {
12+
String accessKey = "your access key";
13+
String secretKey = "your secret key";
14+
Auth auth = Auth.create(accessKey, secretKey);
15+
CdnManager c = new CdnManager(auth);
16+
//待刷新的目录列表,目录必须以 / 结尾
17+
String[] dirs = new String[]{
18+
"http://javasdk.qiniudn.com/gopher1/",
19+
"http://javasdk.qiniudn.com/gopher2/",
20+
//....
21+
};
22+
try {
23+
//单次方法调用刷新的目录不可以超过10个,另外刷新目录权限需要联系技术支持开通
24+
CdnResult.RefreshResult result = c.refreshDirs(dirs);
25+
System.out.println(result.code);
26+
//获取其他的回复内容
27+
} catch (QiniuException e) {
28+
System.err.println(e.response.toString());
29+
}
30+
}
3131

3232
}

examples/DomainListDemo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import com.qiniu.common.QiniuException;
32
import com.qiniu.common.Zone;
43
import com.qiniu.http.Response;
@@ -22,8 +21,8 @@ public static void main(String args[]) {
2221

2322
try {
2423
String[] domainLists = bucketManager.domainList(bucket);
25-
for(String domain : domainLists)
26-
System.out.print(domain);
24+
for (String domain : domainLists)
25+
System.out.print(domain);
2726

2827
} catch (QiniuException e) {
2928

examples/GetBucketInfo.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
import com.qiniu.storage.model.BucketInfo;
66

77
public class GetBucketInfo {
8-
8+
99
//设置需要操作的账号的AK和SK
1010
String ACCESS_KEY = "Access_Key";
1111
String SECRET_KEY = "Secret_Key";
1212
Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
13-
13+
1414
//指定区域,可以用 Zone.autoZone() 自动获取
1515
Zone z = Zone.zone0();
1616
Configuration c = new Configuration(z);
17-
17+
1818
//实例化一个BucketManager对象
1919
BucketManager bucketManager = new BucketManager(auth, c);
20-
20+
2121
// 空间名
2222
String bucket = "BUCKET";
23-
23+
2424
public static void main(String[] args) {
2525
new GetBucketInfo().getBucketInfo();
2626
}
27-
27+
2828
public void getBucketInfo() {
2929
try {
3030
BucketInfo bucketInfo = bucketManager.getBucketInfo(bucket);
3131
// 输出空间私有性
3232
System.out.println(bucketInfo.getPrivate());
3333
// 输出空间所述区域
3434
System.out.println(bucketInfo.getZone());
35-
36-
// 其他参数详见 https://github.com/qiniu/java-sdk/blob/master/src/main/java/com/qiniu/storage/model/BucketInfo.java
37-
35+
36+
// 其他参数详见 https://github.com/qiniu/java-sdk/blob/master/src/main/java/com/qiniu/storage/model/BucketInfo.java
37+
3838
} catch (Exception e) {
3939
//
4040
}

examples/LinkingDemo.java

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,114 +16,113 @@ public class LinkingDemo {
1616
final static String testHost = "http://linking.qiniuapi.com";
1717
final static String testDeviceName1 = "test1";
1818
final static String testDeviceName2 = "test2";
19+
1920
public static void main(String[] args) {
2021

21-
Auth auth = Auth.create(testAk,testSk);
22-
LinkingDeviceManager deviceManager = new LinkingDeviceManager(auth,testHost);
23-
try{
22+
Auth auth = Auth.create(testAk, testSk);
23+
LinkingDeviceManager deviceManager = new LinkingDeviceManager(auth, testHost);
24+
try {
2425
//创建设备
25-
deviceManager.createDevice(testAppid,testDeviceName1);
26-
} catch (QiniuException e){
26+
deviceManager.createDevice(testAppid, testDeviceName1);
27+
} catch (QiniuException e) {
2728
System.out.println(e.error());
2829
}
2930

30-
try{
31+
try {
3132
//添加dak
32-
DeviceKey[] keys = deviceManager.addDeviceKey(testAppid,testDeviceName1);
33+
DeviceKey[] keys = deviceManager.addDeviceKey(testAppid, testDeviceName1);
3334
System.out.println(keys[0].getAccessKey());
3435
System.out.println(keys[0].getSecretKey());
35-
}catch (QiniuException e){
36+
} catch (QiniuException e) {
3637
System.out.println(e.error());
3738
}
3839

39-
try{
40+
try {
4041
//查询设备
41-
DeviceKey[] keys = deviceManager.queryDeviceKey(testAppid,testDeviceName1);
42-
if (keys.length==1){
43-
throw new QiniuException(new Exception(),"expect one length");
42+
DeviceKey[] keys = deviceManager.queryDeviceKey(testAppid, testDeviceName1);
43+
if (keys.length == 1) {
44+
throw new QiniuException(new Exception(), "expect one length");
4445
}
4546
//删除设备
46-
deviceManager.deleteDeviceKey(testAppid,testDeviceName1,keys[0].getAccessKey());
47-
keys = deviceManager.queryDeviceKey(testAppid,testDeviceName1);
48-
if (keys.length==0){
49-
throw new QiniuException(new Exception(),"expect zero length");
47+
deviceManager.deleteDeviceKey(testAppid, testDeviceName1, keys[0].getAccessKey());
48+
keys = deviceManager.queryDeviceKey(testAppid, testDeviceName1);
49+
if (keys.length == 0) {
50+
throw new QiniuException(new Exception(), "expect zero length");
5051
}
51-
}catch (QiniuException e){
52+
} catch (QiniuException e) {
5253
System.out.println(e.error());
5354
}
5455

55-
try{
56+
try {
5657
//列出设备
57-
DeviceListing deviceslist = deviceManager.listDevice(testAppid,"","", 1,false);
58+
DeviceListing deviceslist = deviceManager.listDevice(testAppid, "", "", 1, false);
5859
System.out.println(deviceslist.items.length);
59-
}catch (QiniuException e){
60+
} catch (QiniuException e) {
6061
System.out.println(e.error());
6162
}
6263

6364

64-
65-
try{
65+
try {
6666
//修改设备字段
67-
PatchOperation[] operations={new PatchOperation("replace","segmentExpireDays",9)};
68-
Device device= deviceManager.updateDevice(testAppid,testDeviceName1,operations);
67+
PatchOperation[] operations = {new PatchOperation("replace", "segmentExpireDays", 9)};
68+
Device device = deviceManager.updateDevice(testAppid, testDeviceName1, operations);
6969
System.out.println(device.getSegmentExpireDays());
70-
}catch (QiniuException e){
70+
} catch (QiniuException e) {
7171
System.out.println(e.error());
7272
}
7373

7474

75-
try{
75+
try {
7676
//查询设备在线历史记录
77-
DeviceHistoryListing history= deviceManager.listDeviceHistory(testAppid,testDeviceName1,
78-
0,(new Date().getTime())/1000,"",0);
79-
}catch (QiniuException e){
77+
DeviceHistoryListing history = deviceManager.listDeviceHistory(testAppid, testDeviceName1,
78+
0, (new Date().getTime()) / 1000, "", 0);
79+
} catch (QiniuException e) {
8080
System.out.println(e.error());
8181
}
8282

8383

84-
85-
try{
84+
try {
8685
//删除设备信息
87-
deviceManager.deleteDevice(testAppid,testDeviceName1);
88-
} catch (QiniuException e){
86+
deviceManager.deleteDevice(testAppid, testDeviceName1);
87+
} catch (QiniuException e) {
8988
System.out.println(e.error());
9089
}
9190

92-
try{
93-
deviceManager.createDevice(testAppid,testDeviceName1);
94-
deviceManager.createDevice(testAppid,testDeviceName2);
91+
try {
92+
deviceManager.createDevice(testAppid, testDeviceName1);
93+
deviceManager.createDevice(testAppid, testDeviceName2);
9594

9695
//添加dak
97-
deviceManager.addDeviceKey(testAppid,testDeviceName1);
98-
DeviceKey[] keys = deviceManager.queryDeviceKey(testAppid,testDeviceName1);
96+
deviceManager.addDeviceKey(testAppid, testDeviceName1);
97+
DeviceKey[] keys = deviceManager.queryDeviceKey(testAppid, testDeviceName1);
9998
String dak = keys[0].getAccessKey();
10099

101100
//移动dak
102-
deviceManager.cloneDeviceKey(testAppid,testDeviceName1,testDeviceName2,true, false,dak);
101+
deviceManager.cloneDeviceKey(testAppid, testDeviceName1, testDeviceName2, true, false, dak);
103102
Device device = deviceManager.getDeviceByAccessKey(dak);
104103
device.getDeviceName();
105104

106-
deviceManager.deleteDeviceKey(testAppid,testDeviceName2,dak);
105+
deviceManager.deleteDeviceKey(testAppid, testDeviceName2, dak);
107106

108107
String token;
109108
//生成具有所有功能的token
110-
String[] actions = new String[]{Auth.DTOKEN_ACTION_STATUS,Auth.DTOKEN_ACTION_VOD,Auth.DTOKEN_ACTION_TUTK};
111-
token = auth.generateLinkingDeviceTokenWithExpires(testAppid,testDeviceName1,1000,actions);
109+
String[] actions = new String[]{Auth.DTOKEN_ACTION_STATUS, Auth.DTOKEN_ACTION_VOD, Auth.DTOKEN_ACTION_TUTK};
110+
token = auth.generateLinkingDeviceTokenWithExpires(testAppid, testDeviceName1, 1000, actions);
112111
//生成视频相关功能的token
113-
token = auth.generateLinkingDeviceVodTokenWithExpires(testAppid,testDeviceName1,1000,actions);
112+
token = auth.generateLinkingDeviceVodTokenWithExpires(testAppid, testDeviceName1, 1000, actions);
114113
//生成获取设备状态的token
115-
token = auth.generateLinkingDeviceStatusTokenWithExpires(testAppid,testDeviceName1,1000,actions);
114+
token = auth.generateLinkingDeviceStatusTokenWithExpires(testAppid, testDeviceName1, 1000, actions);
116115

117-
}catch (QiniuException e){
116+
} catch (QiniuException e) {
118117
System.out.println(e.error());
119-
}finally {
120-
try{
121-
deviceManager.deleteDevice(testAppid,testDeviceName1);
122-
}catch (Exception ignored){
118+
} finally {
119+
try {
120+
deviceManager.deleteDevice(testAppid, testDeviceName1);
121+
} catch (Exception ignored) {
123122
}
124-
try{
125-
deviceManager.deleteDevice(testAppid,testDeviceName2);
126-
}catch (Exception ignored){
123+
try {
124+
deviceManager.deleteDevice(testAppid, testDeviceName2);
125+
} catch (Exception ignored) {
127126
}
128127
}
129128

0 commit comments

Comments
 (0)