Skip to content

Commit 1d09325

Browse files
author
YangSen-qn
committed
Merge branch 'master' of YangSen-qn:qiniu/java-sdk
2 parents ddb92a8 + 8d3cc04 commit 1d09325

14 files changed

+85
-63
lines changed

.github/workflows/version-check.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Java SDK Version Check
2+
on:
3+
push:
4+
tags:
5+
- "v[0-9]+.[0-9]+.[0-9]+"
6+
jobs:
7+
linux:
8+
name: Version Check
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
- name: Set env
14+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
15+
- name: Check
16+
run: |
17+
set -e
18+
grep -qF "## ${RELEASE_VERSION}" CHANGELOG.md
19+
grep -qF "public static final String VERSION = \"${RELEASE_VERSION}\";" src/main/java/com/qiniu/common/Constants.java

src/main/java/com/qiniu/storage/Api.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ public String getPath() throws QiniuException {
506506
* @throws QiniuException 组装 query 时的异常,一般为缺失必要参数的异常
507507
*/
508508
protected void buildPath() throws QiniuException {
509-
path = "/" + StringUtils.join(pathSegments, "/");
509+
path = StringUtils.join(pathSegments, "");
510510
}
511511

512512

src/main/java/com/qiniu/storage/ApiQueryRegion.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ protected void buildQuery() throws QiniuException {
8787

8888
@Override
8989
protected void buildPath() throws QiniuException {
90-
addPathSegment("v4");
91-
addPathSegment("query");
90+
addPathSegment("/v4");
91+
addPathSegment("/query");
9292
super.buildPath();
9393
}
9494
}

src/main/java/com/qiniu/storage/ApiUploadV1MakeBlock.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ protected void buildPath() throws QiniuException {
135135
ApiUtils.throwInvalidRequestParamException("block size");
136136
}
137137

138-
addPathSegment("mkblk");
139-
addPathSegment(blockSize + "");
138+
addPathSegment("/mkblk");
139+
addPathSegment("/" + blockSize);
140140
super.buildPath();
141141
}
142142

src/main/java/com/qiniu/storage/ApiUploadV1MakeFile.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -171,35 +171,35 @@ protected void buildPath() throws QiniuException {
171171
ApiUtils.throwInvalidRequestParamException("file size");
172172
}
173173

174-
addPathSegment("mkfile");
175-
addPathSegment(fileSize + "");
174+
addPathSegment("/mkfile");
175+
addPathSegment("/" + fileSize);
176176

177177
if (!StringUtils.isNullOrEmpty(fileMimeType)) {
178-
addPathSegment("mimeType");
179-
addPathSegment(UrlSafeBase64.encodeToString(fileMimeType));
178+
addPathSegment("/mimeType");
179+
addPathSegment("/" + UrlSafeBase64.encodeToString(fileMimeType));
180180
}
181181

182182
if (!StringUtils.isNullOrEmpty(fileName)) {
183-
addPathSegment("fname");
184-
addPathSegment(UrlSafeBase64.encodeToString(fileName));
183+
addPathSegment("/fname");
184+
addPathSegment("/" + UrlSafeBase64.encodeToString(fileName));
185185
}
186186

187187
if (key != null) {
188-
addPathSegment("key");
189-
addPathSegment(UrlSafeBase64.encodeToString(key));
188+
addPathSegment("/key");
189+
addPathSegment("/" + UrlSafeBase64.encodeToString(key));
190190
}
191191

192192
if (params != null && !params.isEmpty()) {
193193
for (String key : params.keySet()) {
194-
addPathSegment(key);
195-
addPathSegment(UrlSafeBase64.encodeToString("" + params.get(key)));
194+
addPathSegment("/" + key);
195+
addPathSegment("/" + UrlSafeBase64.encodeToString("" + params.get(key)));
196196
}
197197
}
198198

199199
if (metaDataParam != null && !metaDataParam.isEmpty()) {
200200
for (String key : metaDataParam.keySet()) {
201-
addPathSegment(key);
202-
addPathSegment(UrlSafeBase64.encodeToString("" + metaDataParam.get(key)));
201+
addPathSegment("/" + key);
202+
addPathSegment("/" + UrlSafeBase64.encodeToString("" + metaDataParam.get(key)));
203203
}
204204
}
205205

src/main/java/com/qiniu/storage/ApiUploadV1PutChunk.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ protected void buildPath() throws QiniuException {
140140
ApiUtils.throwInvalidRequestParamException("block last context");
141141
}
142142

143-
addPathSegment("bput");
144-
addPathSegment(blockLastContext);
145-
addPathSegment(chunkOffset + "");
143+
addPathSegment("/bput");
144+
addPathSegment("/" + blockLastContext);
145+
addPathSegment("/" + chunkOffset);
146146
super.buildPath();
147147
}
148148

src/main/java/com/qiniu/storage/ApiUploadV2AbortUpload.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ protected void buildPath() throws QiniuException {
113113
}
114114

115115
String bucket = token.getBucket();
116-
addPathSegment("buckets");
117-
addPathSegment(bucket);
118-
addPathSegment("objects");
119-
addPathSegment(ApiUtils.resumeV2EncodeKey(key));
120-
addPathSegment("uploads");
121-
addPathSegment(uploadId);
116+
addPathSegment("/buckets");
117+
addPathSegment("/" + bucket);
118+
addPathSegment("/objects");
119+
addPathSegment("/" + ApiUtils.resumeV2EncodeKey(key));
120+
addPathSegment("/uploads");
121+
addPathSegment("/" + uploadId);
122122
super.buildPath();
123123
}
124124
}

src/main/java/com/qiniu/storage/ApiUploadV2CompleteUpload.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ protected void buildPath() throws QiniuException {
191191
}
192192

193193
String bucket = token.getBucket();
194-
addPathSegment("buckets");
195-
addPathSegment(bucket);
196-
addPathSegment("objects");
197-
addPathSegment(ApiUtils.resumeV2EncodeKey(key));
198-
addPathSegment("uploads");
199-
addPathSegment(uploadId);
194+
addPathSegment("/buckets");
195+
addPathSegment("/" + bucket);
196+
addPathSegment("/objects");
197+
addPathSegment("/" + ApiUtils.resumeV2EncodeKey(key));
198+
addPathSegment("/uploads");
199+
addPathSegment("/" + uploadId);
200200
super.buildPath();
201201
}
202202

src/main/java/com/qiniu/storage/ApiUploadV2InitUpload.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ protected void buildPath() throws QiniuException {
105105
}
106106

107107
String bucket = getUploadToken().getBucket();
108-
addPathSegment("buckets");
109-
addPathSegment(bucket);
110-
addPathSegment("objects");
111-
addPathSegment(ApiUtils.resumeV2EncodeKey(key));
112-
addPathSegment("uploads");
108+
addPathSegment("/buckets");
109+
addPathSegment("/" + bucket);
110+
addPathSegment("/objects");
111+
addPathSegment("/" + ApiUtils.resumeV2EncodeKey(key));
112+
addPathSegment("/uploads");
113113
super.buildPath();
114114
}
115115
}

src/main/java/com/qiniu/storage/ApiUploadV2ListParts.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ protected void buildPath() throws QiniuException {
152152
}
153153

154154
String bucket = token.getBucket();
155-
addPathSegment("buckets");
156-
addPathSegment(bucket);
157-
addPathSegment("objects");
158-
addPathSegment(ApiUtils.resumeV2EncodeKey(key));
159-
addPathSegment("uploads");
160-
addPathSegment(uploadId);
155+
addPathSegment("/buckets");
156+
addPathSegment("/" + bucket);
157+
addPathSegment("/objects");
158+
addPathSegment("/" + ApiUtils.resumeV2EncodeKey(key));
159+
addPathSegment("/uploads");
160+
addPathSegment("/" + uploadId);
161161
super.buildPath();
162162
}
163163
}

src/main/java/com/qiniu/storage/ApiUploadV2UploadPart.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ protected void buildPath() throws QiniuException {
162162
}
163163

164164
String bucket = getUploadToken().getBucket();
165-
addPathSegment("buckets");
166-
addPathSegment(bucket);
167-
addPathSegment("objects");
168-
addPathSegment(ApiUtils.resumeV2EncodeKey(key));
169-
addPathSegment("uploads");
170-
addPathSegment(uploadId);
171-
addPathSegment(partNumber + "");
165+
addPathSegment("/buckets");
166+
addPathSegment("/" + bucket);
167+
addPathSegment("/objects");
168+
addPathSegment("/" + ApiUtils.resumeV2EncodeKey(key));
169+
addPathSegment("/uploads");
170+
addPathSegment("/" + uploadId);
171+
addPathSegment("/" + partNumber);
172172
super.buildPath();
173173
}
174174

src/main/java/com/qiniu/storage/DownloadPrivateCloudUrl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ protected void willBuildUrl() throws QiniuException {
6060

6161
@Override
6262
protected void willSetKeyForUrl(Api.Request request) throws QiniuException {
63-
request.addPathSegment("getfile");
64-
request.addPathSegment(accessKey);
65-
request.addPathSegment(bucketName);
63+
request.addPathSegment("/getfile");
64+
request.addPathSegment("/" + accessKey);
65+
request.addPathSegment("/" + bucketName);
6666
super.willSetKeyForUrl(request);
6767
}
6868

src/main/java/com/qiniu/storage/DownloadUrl.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public DownloadUrl setFop(String fop) {
9090
* 配置 style【可选】
9191
* 如果觉得 fop 这样的形式够冗长,还可以为这些串行的 fop 集合定义一个友好别名。如此一来,就可以用友好URL风格进行访问,这个别名就是 style 。
9292
* eg:
93-
* 对 userBucket 的 fop(imageView2/2/w/320/h/480) 使用 style 的方式, 分隔符为 "-"
94-
* 使用 qrsctl 命令定义 style: (qrsctl separator [bucket] [styleSeparator])
95-
* qrsctl separator userBucket -
96-
* 定义数据处理的别名为 aliasName: (qrsctl style [bucket] [aliasName] [fop])
97-
* qrsctl style userBucket iphone imageView2/2/w/320/h/480
93+
* 对 userBucket 的 fop(imageView2/2/w/320/h/480) 使用 style 的方式, 分隔符为 "-"
94+
* 使用 qrsctl 命令定义 style: (qrsctl separator [bucket] [styleSeparator])
95+
* qrsctl separator userBucket -
96+
* 定义数据处理的别名为 aliasName: (qrsctl style [bucket] [aliasName] [fop])
97+
* qrsctl style userBucket iphone imageView2/2/w/320/h/480
9898
* <p>
9999
* <a href="https://developer.qiniu.com/dora/6217/directions-for-use-pfop"> 相关链接 </a>
100100
*
@@ -159,7 +159,7 @@ public String buildURL() throws QiniuException {
159159
}
160160
}
161161
if (!StringUtils.isNullOrEmpty(keyAndStyle)) {
162-
request.addPathSegment(keyAndStyle);
162+
request.addPathSegment("/" + keyAndStyle);
163163
}
164164
didSetKeyForUrl(request);
165165

src/test/java/test/com/qiniu/storage/DownloadUrlTest.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
import org.junit.jupiter.api.Tag;
1111
import org.junit.jupiter.api.Test;
1212
import test.com.qiniu.TestConfig;
13+
1314
import static org.junit.jupiter.api.Assertions.assertEquals;
1415
import static org.junit.jupiter.api.Assertions.assertFalse;
1516
import static org.junit.jupiter.api.Assertions.assertNotNull;
1617
import static org.junit.jupiter.api.Assertions.assertTrue;
1718
import static org.junit.jupiter.api.Assertions.fail;
19+
1820
import java.net.URLEncoder;
19-
import java.nio.charset.Charset;
20-
import java.nio.charset.StandardCharsets;
2121
import java.util.Date;
2222
import java.util.HashMap;
2323
import java.util.Map;
@@ -80,8 +80,11 @@ public void testSpecialKey() {
8080
String encodeKey = keys.get(key);
8181
try {
8282
String url = new DownloadUrl(domain, false, key).buildURL();
83-
String exceptUrl = "http://" + domain + "/" + encodeKey;
84-
assertEquals(exceptUrl, url, "url:" + url + " exceptUrl:" + exceptUrl);
83+
String exceptUrl = "http://" + domain;
84+
if (!key.isEmpty()) {
85+
exceptUrl += "/" + encodeKey;
86+
}
87+
assertEquals(exceptUrl, url, "key:" + key);
8588
} catch (QiniuException e) {
8689
fail(e.error());
8790
}

0 commit comments

Comments
 (0)