Skip to content

Commit 0e81e19

Browse files
authored
Merge pull request #447 from qiniu/develop
dev to master
2 parents 8942884 + f583475 commit 0e81e19

Some content is hidden

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

57 files changed

+3571
-1970
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#Changelog
2+
## 8.1.0 (2020-12-25)
3+
* 支持分片上传V2
4+
* 支持自定义meta
5+
* Zone信息全局缓存
6+
27
## 8.0.5 (2020-11-24)
38
* 缩短Host全局冻结默认时间
49
* 优化无可用Host的处理逻辑

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ https://github.com/qiniudemo/qiniu-lab-android
1515

1616
| Qiniu SDK 版本 | 最低 Android版本 | 依赖库版本 |
1717
|------------ |-----------------|------------------------|
18+
| 8.1.x | Android 5.0+ | okhttp 4+ |
1819
| 8.0.x | Android 5.0+ | okhttp 4+ |
1920
| 7.7.x | Android 5.0+ | okhttp 4+ |
2021
| 7.6.x | Android 5.0+ | okhttp 4+ |
@@ -27,7 +28,7 @@ https://github.com/qiniudemo/qiniu-lab-android
2728
| 7.0.7 | Android 2.2+ | android-async-http 1.4.8 |
2829

2930
### 注意
30-
* 推荐使用最新版:8.0.5
31+
* 推荐使用最新版:8.1.0
3132
* AndroidNetwork.getMobileDbm()可以获取手机信号强度,需要如下权限(API>=18时生效)
3233
```
3334
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
@@ -45,10 +46,10 @@ https://github.com/qiniudemo/qiniu-lab-android
4546
* Android Studio中添加dependencies 或者 在项目中添加maven依赖
4647
```
4748
// 1. 直接导入
48-
implementation 'com.qiniu:qiniu-android-sdk:8.0.+'
49+
implementation 'com.qiniu:qiniu-android-sdk:8.1.+'
4950
5051
// 2. 如果要修改okhttp依赖的版本,可采用以下方式(强烈建议使用七牛库依赖的okhttp版本)
51-
implementation ('com.qiniu:qiniu-android-sdk:8.0.+'){
52+
implementation ('com.qiniu:qiniu-android-sdk:8.1.+'){
5253
exclude (group: 'com.squareup.okhttp3', module: 'okhttp')
5354
}
5455
implementation 'com.squareup.okhttp3:okhttp:4.2.2'

doc/Android_Changes_from_7.x_to_8.0.0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@
163163
- com.qiniu.android.http.request.IUploadRegion
164164
- com.qiniu.android.http.request.Request
165165
- com.qiniu.android.http.request.RequestTransaction
166-
- com.qiniu.android.http.request.UploadFileInfo
167-
- com.qiniu.android.http.request.UploadFileInfo.UploadBlock
168-
- com.qiniu.android.http.request.UploadFileInfo.UploadData
166+
- com.qiniu.android.storage.UploadFileInfo
167+
- com.qiniu.android.storage.UploadFileInfo.UploadBlock
168+
- com.qiniu.android.storage.UploadFileInfo.UploadData
169169

170170

171171
## 9 com.qiniu.android.http.request.handler
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Jul 14 16:33:29 CST 2020
1+
#Wed Dec 23 14:42:43 CST 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

library/library.iml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
3232
<exclude-output />
3333
<content url="file://$MODULE_DIR$">
34-
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
35-
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
36-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
3734
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
35+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
36+
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
37+
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
3838
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
3939
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" generated="true" />
4040
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
4141
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
42-
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
4342
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
43+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
4444
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
4545
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" generated="true" />
4646
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />

library/src/androidTest/java/com/qiniu/android/CancelTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testFile() throws Throwable {
5050
checkTemp(ts, "testFile");
5151
}
5252

53-
public void testMultiFile() throws Throwable {
53+
public void testMultiFileA() throws Throwable {
5454
Temp[] ts = new Temp[]{templateFile(400, 0.2), templateFile(700, 0.2), templateFile(1024, 0.51), templateFile(4 * 1024, 0.5), templateFile(8 * 1024 + 1, 0.6)};
5555
checkTemp(ts, "testFile");
5656
}
@@ -84,7 +84,7 @@ private void checkTemp(Temp[] ts, String type) {
8484
private Temp templateFile(final int size, final double pos) throws Throwable {
8585
final CountDownLatch signal = new CountDownLatch(1);
8686
final File tempFile = TempFile.createFile(size);
87-
final String expectKey = "file_" + UUID.randomUUID().toString();
87+
final String expectKey = "file_" + size;
8888
Map<String, String> params = new HashMap<String, String>();
8989
params.put("x:a", "test");
9090
params.put("x:b", "test2");
@@ -301,7 +301,7 @@ public void complete(String k, ResponseInfo rinfo, JSONObject response) {
301301
wait(waitCondition, 10 * 60);
302302

303303
assertTrue(temp.info != null);
304-
assertTrue(temp.info.isOK());
304+
assertTrue(temp.info.toString(), temp.info.isOK());
305305

306306
TempFile.remove(tempFile);
307307
}

library/src/androidTest/java/com/qiniu/android/ComplexUploadSceneTest.java

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.test.AndroidTestCase;
44
import android.util.Log;
55

6+
import com.qiniu.android.common.Config;
67
import com.qiniu.android.http.ResponseInfo;
78
import com.qiniu.android.storage.Configuration;
89
import com.qiniu.android.storage.UpCompletionHandler;
@@ -17,32 +18,49 @@
1718
import java.util.concurrent.CountDownLatch;
1819
import java.util.concurrent.TimeUnit;
1920

20-
public class ComplexUploadSceneTest extends AndroidTestCase {
21+
public class ComplexUploadSceneTest extends UploadBaseTest {
2122

2223
private final CountDownLatch signal = new CountDownLatch(1);
2324

24-
public void testMutiUpload(){
25+
public void testMutiUploadV1(){
2526

26-
final int maxCount = 10;
27+
final int maxCount = 40;
2728

2829
final TestParam param = new TestParam();
2930
param.completeCount = 0;
3031
param.successCount = 0;
3132

32-
for (int i = 0; i < maxCount; i++) {
33-
template((i + 1) * 100, new CompleteHandler() {
34-
@Override
35-
public void complete(boolean isSuccess) {
33+
final int start = 37;
34+
for (int i = start; i < maxCount; i++) {
35+
Configuration config = new Configuration.Builder()
36+
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V1)
37+
.useConcurrentResumeUpload(true)
38+
.concurrentTaskCount(3)
39+
.chunkSize((i%4 + 1) * 1024 * 1024 + i)
40+
.build();
41+
42+
int size = (i + 1) * 1024;
43+
final String keyUp = "android_complex_upload_v1_" + size + "k";
44+
File file = null;
45+
try {
46+
file = TempFile.createFile(size);
47+
} catch (IOException e) {
48+
continue;
49+
}
3650

51+
uploadFile(file, keyUp, config, null, new UpCompletionHandler() {
52+
@Override
53+
public void complete(String key, ResponseInfo info, JSONObject response) {
3754
synchronized (param){
3855
param.completeCount += 1;
39-
if (isSuccess){
56+
if (info != null && info.isOK()){
4057
param.successCount += 1;
4158
}
42-
if (param.completeCount == maxCount){
59+
if (param.completeCount == (maxCount - start)){
4360
signal.countDown();
4461
}
4562
}
63+
Log.d("upload key:" + keyUp, "complex_upload_v1 response: " + info);
4664
}
4765
});
4866
}
@@ -52,40 +70,60 @@ public void complete(boolean isSuccess) {
5270
} catch (InterruptedException e) {
5371
}
5472

55-
Log.d("ComplexUploadSceneTest", "complex_upload successCount: " + param.successCount);
73+
Log.d("ComplexUploadSceneTest", "complex_upload_v1 successCount: " + param.successCount);
5674
assertTrue("success count" + param.successCount, param.successCount == param.completeCount);
5775
}
5876

59-
private void template(int size, final CompleteHandler completeHandler){
77+
public void testMutiUploadV2(){
6078

61-
final String keyUp = "android_complex_upload_" + size + "k";
62-
File file = null;
63-
try {
64-
file = TempFile.createFile(size);
65-
} catch (IOException e) {
66-
completeHandler.complete(false);
67-
return;
68-
}
79+
final int maxCount = 40;
6980

70-
Configuration configuration = new Configuration.Builder()
71-
.useHttps(true)
72-
.build();
73-
UploadManager manager = new UploadManager(configuration);
74-
75-
manager.put(file, keyUp, TestConfig.token_na0, new UpCompletionHandler() {
76-
@Override
77-
public void complete(String key, ResponseInfo info, JSONObject response) {
78-
if (info.isOK() && info.reqId != null && keyUp.equals(key)){
79-
completeHandler.complete(true);
80-
} else {
81-
completeHandler.complete(false);
82-
}
81+
final TestParam param = new TestParam();
82+
param.completeCount = 0;
83+
param.successCount = 0;
84+
85+
final int start = 37;
86+
for (int i = start; i < maxCount; i++) {
87+
Configuration config = new Configuration.Builder()
88+
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V2)
89+
.useConcurrentResumeUpload(true)
90+
.concurrentTaskCount(3)
91+
.chunkSize((i%4 + 1) * 1024 * 1024 + i)
92+
.build();
93+
94+
int size = (i + 1) * 1024;
95+
final String keyUp = "android_complex_upload_v2_" + size + "k";
96+
File file = null;
97+
try {
98+
file = TempFile.createFile(size);
99+
} catch (IOException e) {
100+
continue;
83101
}
84-
}, null);
85-
}
86102

87-
private interface CompleteHandler{
88-
void complete(boolean isSuccess);
103+
uploadFile(file, keyUp, config, null, new UpCompletionHandler() {
104+
@Override
105+
public void complete(String key, ResponseInfo info, JSONObject response) {
106+
synchronized (param){
107+
param.completeCount += 1;
108+
if (info != null && (info.isOK() || info.statusCode == 614)){
109+
param.successCount += 1;
110+
}
111+
if (param.completeCount == (maxCount - start)){
112+
signal.countDown();
113+
}
114+
}
115+
Log.d("upload key:" + keyUp, "complex_upload_v2 response: " + info);
116+
}
117+
});
118+
}
119+
120+
try {
121+
signal.await(); // wait for callback
122+
} catch (InterruptedException e) {
123+
}
124+
125+
Log.d("ComplexUploadSceneTest", "complex_upload_v2 successCount: " + param.successCount);
126+
assertTrue("success count" + param.successCount, param.successCount == (param.completeCount));
89127
}
90128

91129

0 commit comments

Comments
 (0)