Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3334c93
suport upload stream
Apr 23, 2021
4c389ae
support input stream & Uri
Apr 26, 2021
deeeaf2
fix upload source logic
Apr 26, 2021
bbf1136
fix switch region logic
Apr 26, 2021
7d8cd30
change read and check source logic
Apr 28, 2021
986b62d
Uri param add resolver & change progress logic
Apr 29, 2021
8a4044d
change progress logic
Apr 29, 2021
57c5ca4
change resume upload case
Apr 29, 2021
32c07df
forbid ipv6 if needed
May 6, 2021
865460d
change version to 8.3.0
May 7, 2021
eab8380
modify form upload testCancel test case assert
May 7, 2021
86c71ac
optimize uri source read logic
May 8, 2021
8451c80
change UploadManager InputStream api desc
May 8, 2021
7818723
upload file check md5
May 8, 2021
29b707a
optimize upload info
May 10, 2021
0989388
change upload source func name reloadInfo
May 10, 2021
b6e26df
change UploadInfo func name: reloadInfo -> reloadSource
May 10, 2021
3e157d6
change ipv6 check logic
May 11, 2021
b1f4733
change upload v2 api data index logic
May 11, 2021
c85c582
change upload api v1 ctx logic
May 12, 2021
177ea23
change model to json logic
May 12, 2021
b7d110e
modify http client logic
May 13, 2021
93f0fbf
change group task & http client logic
May 13, 2021
c7f9a7f
optimize data state logic
May 13, 2021
b2dbf6a
change resume upload data read logic
May 17, 2021
22c233a
optimize resume upload read data logic
May 17, 2021
61f202c
optimize resume upload v2 read data logic
May 17, 2021
0c7cf2c
optimize resume upload performer read data logic
May 18, 2021
32ca54b
supoort okhttp 3.12.1
May 18, 2021
861f040
upgrade happy dns to 0.2.18
May 19, 2021
6885675
add UriTest case
May 21, 2021
0a0bf97
uri test case change key
May 21, 2021
49ebc4f
change CI api level to 30 & Uri test check etag
May 21, 2021
9e640b1
change ci api level to 29
May 21, 2021
2342591
change ci
May 21, 2021
95869d3
change ci
May 21, 2021
a43efe5
change ci
May 21, 2021
3043bd4
android ci test api level to 22
May 24, 2021
111f35f
change Uri test case
May 24, 2021
b4599b5
ci api level to 26
May 24, 2021
6b91a14
change uri test
May 24, 2021
c85473e
uri test case check except
May 24, 2021
76601ba
uri test check exception
May 24, 2021
9dc0241
change uri test case
May 24, 2021
292a869
ci api level to 22
May 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 22
profile: Nexus 6
arch: x86_64
script: |
./gradlew connectedCheck
./gradlew build
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#Changelog
## 8.3.0(2021-05-12)
* 支持资源通过 Uri 和 InputStream 方式上传

## 8.2.1(2021-04-14)
* 优化分片上传逻辑,增加重试

## 8.2.0(2021-02-20)
## 增加
* 增加网络监控功能,选择最优 Host 进行上传
* 优化日志统计

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ https://github.com/qiniudemo/qiniu-lab-android

| Qiniu SDK 版本 | 最低 Android版本 | 依赖库版本 |
|------------ |-----------------|------------------------|
| 8.3.x | Android 5.0+ | okhttp 4+ |
| 8.2.x | Android 5.0+ | okhttp 4+ |
| 8.1.x | Android 5.0+ | okhttp 4+ |
| 8.0.x | Android 5.0+ | okhttp 4+ |
Expand All @@ -29,7 +30,7 @@ https://github.com/qiniudemo/qiniu-lab-android
| 7.0.7 | Android 2.2+ | android-async-http 1.4.8 |

### 注意
* 推荐使用最新版:8.2.1
* 推荐使用最新版:8.3.0
* AndroidNetwork.getMobileDbm()可以获取手机信号强度,需要如下权限(API>=18时生效)
```
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down
5 changes: 3 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
buildToolsVersion '29.0.2'
defaultConfig {
//applicationId "com.qiniu.android"
minSdkVersion 15
minSdkVersion 19
targetSdkVersion 26
versionCode code
versionName version
Expand Down Expand Up @@ -52,7 +52,8 @@ android {

dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.qiniu:happy-dns:0.2.16'
// implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.qiniu:happy-dns:0.2.18'
// for javax.annotation.Nullable use in custom MultipartBody and Headers implements.
// implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.conscrypt:conscrypt-android:2.2.1'
Expand Down
2 changes: 1 addition & 1 deletion library/library.iml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.3.50@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.qiniu:happy-dns:0.2.16@jar" level="project" />
<orderEntry type="library" name="Gradle: com.qiniu:happy-dns:0.2.18@jar" level="project" />
<orderEntry type="library" name="Gradle: org.conscrypt:conscrypt-android:2.2.1@aar" level="project" />
<orderEntry type="library" name="Gradle: android.test.mock-android-29" level="project" />
<orderEntry type="library" name="Gradle: android.test.base-android-29" level="project" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public void testMutiUploadV1(){
continue;
}

uploadFile(file, keyUp, config, null, new UpCompletionHandler() {
UploadInfo<File> info = new UploadInfo<>(file);
info.configWithFile(file);
upload(info, keyUp, config, null, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
synchronized (param){
Expand Down Expand Up @@ -100,7 +102,9 @@ public void testMutiUploadV2(){
continue;
}

uploadFile(file, keyUp, config, null, new UpCompletionHandler() {
UploadInfo<File> info = new UploadInfo<>(file);
info.configWithFile(file);
upload(info, keyUp, config, null, new UpCompletionHandler() {
@Override
public void complete(String key, ResponseInfo info, JSONObject response) {
synchronized (param){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public void testCancelV1() {
String key = "android_concurrent_resume_cancel_v1_" + size + "k";
try {
File file = TempFile.createFile(size, key);
cancelTest(cancelPercent, file, key, configuration, null);
cancelTest((long) (size * cancelPercent), file, key, configuration, null);
TempFile.remove(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

public void testHttpV1(){
public void testHttpV1() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V1)
.useConcurrentResumeUpload(true)
Expand All @@ -87,7 +87,7 @@ public void testHttpV1(){
}
}

public void testHttpsV1(){
public void testHttpsV1() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V1)
.useConcurrentResumeUpload(true)
Expand All @@ -106,27 +106,27 @@ public void testHttpsV1(){
}
}

public void testReuploadV1(){
public void testReuploadV1() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V1)
.useConcurrentResumeUpload(true)
.useHttps(true)
.chunkSize(1024*1024)
.chunkSize(1024 * 1024)
.build();
int[] sizeArray = {30000};
for (int size : sizeArray) {
String key = "android_concurrent_resume_reupload_v1_" + size + "k";
try {
File file = TempFile.createFile(size, key);
reuploadUploadTest((float)0.7, file, key, configuration, null);
reuploadUploadTest((long) (size * 0.7), file, key, configuration, null);
TempFile.remove(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

public void testNoKeyV1(){
public void testNoKeyV1() {
int size = 600;
String key = "android_concurrent_resume_no_key_v1_" + size + "k";
File file = null;
Expand All @@ -153,7 +153,7 @@ public void testNoKeyV1(){
TempFile.remove(file);
}

public void test0kV1(){
public void test0kV1() {
int size = 0;
String key = "android_concurrent_resume_0k_v1_" + size + "k";
File file = null;
Expand Down Expand Up @@ -185,7 +185,7 @@ public void testSwitchRegionV2() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V2)
.useConcurrentResumeUpload(true)
.chunkSize(4*1024*1024)
.chunkSize(4 * 1024 * 1024)
.useHttps(true)
.build();
int[] sizeArray = {5000, 8000, 10000, 20000};
Expand All @@ -206,30 +206,30 @@ public void testCancelV2() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V2)
.useConcurrentResumeUpload(true)
.chunkSize(4*1024*1024)
.chunkSize(4 * 1024 * 1024)
.useHttps(true)
.build();
int[] sizeArray = {10000, 20000};
for (int size : sizeArray) {
String key = "android_concurrent_resume_cancel_v2_" + size + "k";
try {
File file = TempFile.createFile(size, key);
cancelTest(cancelPercent, file, key, configuration, null);
cancelTest((long) (size * cancelPercent), file, key, configuration, null);
TempFile.remove(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

public void testHttpV2(){
public void testHttpV2() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V2)
.useConcurrentResumeUpload(true)
.chunkSize(4*1024*1024)
.chunkSize(4 * 1024 * 1024)
.useHttps(false)
.build();
int[] sizeArray = {500, 1000, 3000, 4000, 5000, 8000, 10000, 20000};
int[] sizeArray = {500, 2000, 4000, 5000, 8000, 20000};
long timestamp = new Date().getTime();
for (int size : sizeArray) {
String key = "android_concurrent_resume_http_v2_" + timestamp + "_" + size + "k";
Expand All @@ -243,14 +243,14 @@ public void testHttpV2(){
}
}

public void testHttpsV2(){
public void testHttpsV2() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V2)
.useConcurrentResumeUpload(true)
.useHttps(true)
.chunkSize(4*1024*1024)
.chunkSize(4 * 1024 * 1024)
.build();
int[] sizeArray = {500, 1000, 3000, 4000, 5000, 8000, 10000, 20000};
int[] sizeArray = {500, 2000, 4000, 5000, 8000, 20000};
for (int size : sizeArray) {
String key = "android_concurrent_resume_https_v2_" + size + "k";
try {
Expand All @@ -263,27 +263,27 @@ public void testHttpsV2(){
}
}

public void testReuploadV2(){
public void testReuploadV2() {
Configuration configuration = new Configuration.Builder()
.resumeUploadVersion(Configuration.RESUME_UPLOAD_VERSION_V2)
.useConcurrentResumeUpload(true)
.useHttps(true)
.chunkSize(4*1024*1024)
.chunkSize(4 * 1024 * 1024)
.build();
int[] sizeArray = {30000};
for (int size : sizeArray) {
String key = "android_concurrent_resume_reupload_v2_" + size + "k";
try {
File file = TempFile.createFile(size, key);
reuploadUploadTest((float)0.7, file, key, configuration, null);
reuploadUploadTest((long) (size * 0.7), file, key, configuration, null);
TempFile.remove(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

public void testNoKeyV2(){
public void testNoKeyV2() {
int size = 600;
String key = "android_concurrent_resume_no_key_v2_" + size + "k";
File file = null;
Expand All @@ -310,7 +310,7 @@ public void testNoKeyV2(){
TempFile.remove(file);
}

public void test0kV2(){
public void test0kV2() {
int size = 0;
String key = "android_concurrent_resume_0k_v2_" + size + "k";
File file = null;
Expand Down
Loading