Skip to content

Commit ec11d4b

Browse files
committed
update qcloud sdk to 5.6.14
1 parent 03476f6 commit ec11d4b

File tree

57 files changed

+2512
-354
lines changed

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

+2512
-354
lines changed

QCloudCosXml/cosxml-ktx/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
defaultConfig {
99
minSdkVersion 15
1010
targetSdkVersion 29
11-
versionCode 50605
12-
versionName "5.6.5"
11+
versionCode 50614
12+
versionName "5.6.14"
1313

1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
consumerProguardFiles "consumer-rules.pro"
@@ -39,7 +39,7 @@ dependencies {
3939
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
4040
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4"
4141
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4"
42-
implementation 'com.tencent.qcloud:cosxml:5.6.2'
42+
implementation 'com.qcloud.cos:cos-android:5.6.7'
4343

4444
androidTestImplementation 'junit:junit:4.13'
4545
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.4"
@@ -48,7 +48,9 @@ dependencies {
4848

4949
}
5050

51-
project.extensions.add('artifactId', 'cosxml-ktx')
51+
project.extensions.add('artifactId', 'cos-ktx')
5252
project.extensions.add('artifactDesc', 'Tencent COSXml SDK Kotlin Extension')
5353
project.extensions.add('lang', 'kotlin')
54+
project.extensions.add('archiveFilePath', 'outputs/aar/cos-ktx-release.aar')
5455

56+
apply from: '../../publishMavenCentral.gradle'

QCloudCosXml/cosxml/build.gradle

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
apply plugin: 'com.android.library'
22
apply from: '../version.gradle'
33
apply from: 'jacoco.gradle'
4-
apply plugin: 'com.github.dcendents.android-maven'
54

65
def compileQuic() {
76
return getGradle().getStartParameter().getTaskRequests()
@@ -18,8 +17,8 @@ android {
1817
minSdkVersion 15
1918
targetSdkVersion 28
2019

21-
versionCode 50605
22-
versionName "5.6.5"
20+
versionCode 50614
21+
versionName "5.6.14"
2322

2423
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
2524

@@ -70,17 +69,19 @@ android {
7069

7170
// 切换发 normal 或者 slim 包,需要同步修改 pom.artifactId 信息
7271
defaultPublishConfig "normalRelease"
73-
// defaultPublishConfig "slimRelease"
72+
// defaultPublishConfig "slimRelease"
7473

7574
compileOptions {
7675
sourceCompatibility = JavaVersion.VERSION_1_7
7776
targetCompatibility = JavaVersion.VERSION_1_7
7877
}
78+
7979
buildToolsVersion = '28.0.2'
8080

8181
}
8282

8383
dependencies {
84+
8485
compileOnly 'androidx.appcompat:appcompat:1.2.0'
8586
testCompileOnly 'junit:junit:4.13'
8687

@@ -89,7 +90,7 @@ dependencies {
8990
androidTestImplementation 'com.android.support.test:rules:1.0.2'
9091

9192
api project(path: ':foundation')
92-
api project(path: ':logUtils')
93+
// api project(path: ':logUtils')
9394

9495
if (compileQuic() && false) {
9596
api project(path: ':quic')
@@ -99,29 +100,32 @@ dependencies {
99100
annotationProcessor project(':xmlCompiler')
100101

101102
//lite版本使用normalApi
102-
// normalApi 'com.tencent.qcloud:beacon-android-release:4.1.13'
103+
normalApi 'com.qcloud.cos:beacon-android-release:4.1.22.11'
103104
//normal版本使用api
104-
api 'com.tencent.qcloud:beacon-android-release:4.1.13'
105-
slimCompileOnly 'com.tencent.qcloud:beacon-android-release:4.1.13'
105+
// api 'com.qcloud.cos:beacon-android-release:4.1.22.11'
106+
slimCompileOnly 'com.qcloud.cos:beacon-android-release:4.1.22.11'
106107
}
107108

108109

109110
// 发布到 bintray
110111

111112
if (android.defaultPublishConfig.contains("slim")){
112-
project.extensions.add('artifactId', 'cosxml-lite')
113+
project.extensions.add('artifactId', 'cos-android-lite')
113114
project.extensions.add('packageName', 'QCloudCosXmlLite')
114115
project.extensions.add('packageType', 'aar')
115116
project.extensions.add('artifactProduct', 'slim')
116117
project.extensions.add('artifactDesc', 'the tencent cloud cosxml android sdk')
118+
project.extensions.add('archiveName', 'cos-android-slim-release.aar')
119+
project.extensions.add('archiveFilePath', 'outputs/aar/cos-android-lite-slim-release.aar')
117120
}else {
118-
project.extensions.add('artifactId', 'cosxml')
121+
project.extensions.add('artifactId', 'cos-android')
119122
project.extensions.add('packageName', 'QCloudCosXml')
120123
project.extensions.add('packageType', 'aar')
121124
project.extensions.add('artifactProduct', 'normal')
122125
project.extensions.add('artifactDesc', 'the tencent cloud cosxml android sdk')
126+
project.extensions.add('archiveFilePath', 'outputs/aar/cos-android-normal-release.aar')
123127
}
124-
128+
apply from: '../../publishMavenCentral.gradle'
125129

126130

127131
// 发布到内部仓库
@@ -185,3 +189,11 @@ task(printEnvs) {
185189
println('System envs region are :')
186190
println(quotWrapper(System.getenv("REGION")))
187191
}
192+
193+
194+
android.libraryVariants.all { variant ->
195+
variant.outputs.all {
196+
// System.out.println('variant is ' + variant.name)
197+
// outputFileName = "${project.extensions.artifactId}-release.aar"
198+
}
199+
}

QCloudCosXml/cosxml/src/androidTest/java/AndroidManifest.xml renamed to QCloudCosXml/cosxml/src/androidTest/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
2929
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
3030
<application android:allowBackup="true" android:label="@string/app_name"
31+
android:networkSecurityConfig="@xml/network_security_config"
3132
android:supportsRtl="true">
3233

3334
</application>

QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/common/OtherTest.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,30 @@
2222

2323
package com.tencent.cos.xml.common;
2424

25+
import android.os.Environment;
26+
2527
import androidx.test.ext.junit.runners.AndroidJUnit4;
2628

29+
import com.tencent.cos.xml.CosXmlSimpleService;
30+
import com.tencent.cos.xml.core.ServiceFactory;
31+
import com.tencent.cos.xml.core.TestConst;
32+
import com.tencent.cos.xml.core.TestUtils;
33+
import com.tencent.cos.xml.exception.CosXmlClientException;
34+
import com.tencent.cos.xml.exception.CosXmlServiceException;
35+
import com.tencent.cos.xml.listener.CosXmlResultSimpleListener;
36+
import com.tencent.cos.xml.utils.DigestUtils;
37+
import com.tencent.qcloud.core.logger.QCloudLogger;
38+
39+
import org.junit.Assert;
2740
import org.junit.Test;
2841
import org.junit.runner.RunWith;
2942

43+
import java.io.ByteArrayInputStream;
44+
import java.io.File;
45+
import java.io.FileInputStream;
46+
import java.io.FileNotFoundException;
47+
import java.math.BigInteger;
48+
3049
import static org.junit.Assert.assertEquals;
3150

3251
/**
@@ -42,4 +61,56 @@ public void testServerEncryptType(){
4261
assertEquals("SSE-C", ServerEncryptType.SSE_C.getType());
4362
assertEquals(ServerEncryptType.SSE_COS, ServerEncryptType.fromString("SSE-COS"));
4463
}
64+
65+
@Test
66+
public void testGetService() {
67+
CosXmlSimpleService cosXmlSimpleService = ServiceFactory.INSTANCE.newDefaultService();
68+
boolean b = cosXmlSimpleService.preBuildConnection(TestConst.PERSIST_BUCKET);
69+
Assert.assertTrue(b);
70+
}
71+
72+
@Test
73+
public void testGetServiceAsync() {
74+
CosXmlSimpleService cosXmlSimpleService = ServiceFactory.INSTANCE.newDefaultService();
75+
cosXmlSimpleService.preBuildConnectionAsync(TestConst.PERSIST_BUCKET, new CosXmlResultSimpleListener() {
76+
@Override
77+
public void onSuccess() {
78+
Assert.assertTrue(true);
79+
}
80+
81+
@Override
82+
public void onFail(CosXmlClientException exception, CosXmlServiceException serviceException) {
83+
Assert.fail(TestUtils.getCosExceptionMessage(exception, serviceException));
84+
}
85+
});
86+
}
87+
88+
@Test public void testCRC64() {
89+
90+
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "12345.zip");
91+
QCloudLogger.i(TestConst.UT_TAG, "file path is " + file.getAbsolutePath());
92+
93+
BigInteger bi = new BigInteger("9668868296014390415");
94+
QCloudLogger.i(TestConst.UT_TAG, "remote crc64 is " + bi.longValue());
95+
96+
try {
97+
QCloudLogger.i(TestConst.UT_TAG, "file crc64 is " + DigestUtils.getCRC64(new FileInputStream(file)));
98+
// QCloudLogger.i(TestConst.UT_TAG, "file crc64 is " + DigestUtils.getCRC64(new ByteArrayInputStream(
99+
// "123456789".getBytes()
100+
// )));
101+
} catch (Exception e) {
102+
e.printStackTrace();
103+
}
104+
}
105+
106+
@Test public void testGetObjectUrl() {
107+
108+
CosXmlSimpleService defaultService = ServiceFactory.INSTANCE.newDefaultService();
109+
String bucket = "bucket";
110+
String region = "ap-shanghai";
111+
String key = "objectexample";
112+
String url = defaultService.getObjectUrl(bucket, region, key);
113+
QCloudLogger.i("QCloudTest", url);
114+
Assert.assertEquals("https://bucket.cos.ap-shanghai.myqcloud.com/objectexample", url);
115+
}
45116
}

QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/core/ServiceFactory.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.tencent.cos.xml.core;
22

3+
import com.tencent.cos.xml.CosXmlService;
34
import com.tencent.cos.xml.CosXmlServiceConfig;
45
import com.tencent.cos.xml.CosXmlSimpleService;
56
import com.tencent.cos.xml.exception.CosXmlClientException;
@@ -98,17 +99,19 @@ public TransferManager newAccelerateTransferManager() {
9899
.setRegion(TestConst.PERSIST_BUCKET_REGION)
99100
.builder();
100101

101-
return new TransferManager(newService(cosXmlServiceConfig), new TransferConfig.Builder().build());
102+
return new TransferManager(newService(cosXmlServiceConfig), new TransferConfig.Builder()
103+
.setDivisionForUpload(2 * 1024 * 1024)
104+
.setSliceSizeForUpload(1024 * 1024)
105+
.build());
102106
}
103107

104108
public TransferManager newCdnTransferManager() {
105109
return new TransferManager(newCDNService(), new TransferConfig.Builder().build());
106110
}
107111

108112
private CosXmlSimpleService newService(CosXmlServiceConfig cosXmlServiceConfig) {
109-
return new CosXmlSimpleService(getContext(), cosXmlServiceConfig,
113+
return new CosXmlService(getContext(), cosXmlServiceConfig,
110114
new ShortTimeCredentialProvider(TestConst.SECRET_ID, TestConst.SECRET_KEY,600) );
111115

112116
}
113-
114117
}

QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/core/TestConst.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class TestConst {
2121
public static final String PERSIST_BUCKET = BuildConfig.PERSIST_BUCKET;
2222
public static final String PERSIST_BUCKET_CDN_SIGN = BuildConfig.PERSIST_BUCKET_CDN_SIGN;
2323
public static final String PERSIST_BUCKET_PIC_PATH = "/do_not_remove/image.png";
24+
public static final String PERSIST_BUCKET_QR_PATH = "/do_not_remove/qr.png";
25+
public static final String PERSIST_BUCKET_VIDEO_PATH = "/do_not_rembove/video.mp4";
2426
public static final String PERSIST_BUCKET_SELECT_JSON_PATH = "/do_not_remove/select.json";
2527
public static final String PERSIST_BUCKET_SELECT_CSV_PATH = "/do_not_remove/select.csv";
2628
public static final String PERSIST_BUCKET_DOCUMENT_PATH = "/do_not_remove/document.docx";
@@ -30,7 +32,7 @@ public class TestConst {
3032
public static final String PERSIST_BUCKET_REPLICATION = BuildConfig.PERSIST_BUCKET_REPLICATION;
3133
public static final String PERSIST_BUCKET_REPLICATION_REGION = BuildConfig.PERSIST_BUCKET_REPLICATION_REGION;
3234

33-
public static final long PERSIST_BUCKET_SMALL_OBJECT_SIZE = 1024;
35+
public static final long PERSIST_BUCKET_SMALL_OBJECT_SIZE = 1024 * 1024;
3436
public static final long PERSIST_BUCKET_BIG_OBJECT_SIZE = 10 * 1024 * 1024;
3537
public static final String PERSIST_BUCKET_SMALL_OBJECT_PATH = "/do_not_remove/small_object";
3638
public static final String PERSIST_BUCKET_BIG_OBJECT_PATH = "/do_not_remove/big_object";

QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/core/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static String localPath(String subPath) {
8282
if (!subPath.startsWith("/")) {
8383
subPath = "/".concat(subPath);
8484
}
85-
85+
8686
return localParentPath().concat(subPath);
8787
}
8888

QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/image/ImageTest.java renamed to QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/doc/ImageTest.java

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package com.tencent.cos.xml.image;
1+
package com.tencent.cos.xml.doc;
22

3+
import android.os.Environment;
34
import android.util.Log;
45

56
import androidx.test.ext.junit.runners.AndroidJUnit4;
67

7-
import com.tencent.cos.xml.CosXmlSimpleService;
88
import com.tencent.cos.xml.core.ServiceFactory;
99
import com.tencent.cos.xml.core.TestConst;
1010
import com.tencent.cos.xml.core.TestLocker;
@@ -24,7 +24,6 @@
2424
import com.tencent.cos.xml.transfer.COSXMLUploadTask;
2525

2626
import org.junit.Assert;
27-
import org.junit.BeforeClass;
2827
import org.junit.Test;
2928
import org.junit.runner.RunWith;
3029

@@ -33,6 +32,8 @@
3332
import java.util.List;
3433
import java.util.Map;
3534

35+
import static android.os.Environment.DIRECTORY_DOWNLOADS;
36+
3637
/**
3738
* <p>
3839
* Created by rickenwang on 2020/8/14.
@@ -43,19 +44,19 @@ public class ImageTest {
4344

4445
final static String localImageName ="/test_image.png";
4546

46-
@BeforeClass public static void downloadImageToLocalPath() {
47-
48-
TestUtils.removeLocalFile(TestUtils.localPath(localImageName));
49-
GetObjectRequest getObjectRequest = new GetObjectRequest(TestConst.PERSIST_BUCKET,
50-
TestConst.PERSIST_BUCKET_PIC_PATH, TestUtils.localParentPath(), localImageName);
51-
52-
CosXmlSimpleService cosXmlSimpleService = ServiceFactory.INSTANCE.newDefaultService();
53-
try {
54-
cosXmlSimpleService.getObject(getObjectRequest);
55-
} catch (Exception e) {
56-
Assert.fail(e.getMessage());
57-
}
58-
}
47+
// @BeforeClass public static void downloadImageToLocalPath() {
48+
//
49+
// TestUtils.removeLocalFile(TestUtils.localPath(localImageName));
50+
// GetObjectRequest getObjectRequest = new GetObjectRequest(TestConst.PERSIST_BUCKET,
51+
// TestConst.PERSIST_BUCKET_PIC_PATH, TestUtils.localParentPath(), localImageName);
52+
//
53+
// CosXmlSimpleService cosXmlSimpleService = ServiceFactory.INSTANCE.newDefaultService();
54+
// try {
55+
// cosXmlSimpleService.getObject(getObjectRequest);
56+
// } catch (Exception e) {
57+
// Assert.fail(e.getMessage());
58+
// }
59+
// }
5960

6061
// 通过 CosXmlService#putObject() 方法简单上传,返回 PutObjectResult
6162
@Test public void testPicOperationRule() {
@@ -86,6 +87,30 @@ public class ImageTest {
8687
}
8788
}
8889

90+
// 二维码识别
91+
@Test public void testQRCode() {
92+
93+
PutObjectRequest putObjectRequest = new PutObjectRequest(TestConst.PERSIST_BUCKET,
94+
TestConst.PERSIST_BUCKET_PIC_PATH, Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS) + "/Qrcode.jpg");
95+
96+
List<PicOperationRule> rules = new LinkedList<>();
97+
rules.add(new PicOperationRule("/test.png", "QRcode/cover/0"));
98+
PicOperations picOperations = new PicOperations(false, rules);
99+
putObjectRequest.setPicOperations(picOperations);
100+
101+
PutObjectResult putObjectResult = null;
102+
try {
103+
putObjectResult = ServiceFactory.INSTANCE.newDefaultService().putObject(putObjectRequest);
104+
PicUploadResult uploadResult = putObjectResult.picUploadResult();
105+
Assert.assertNotNull(uploadResult);
106+
// Assert.assertFalse(uploadResult.processResults.isEmpty());
107+
Assert.assertEquals(200, putObjectResult.httpCode);
108+
} catch (Exception exception) {
109+
Assert.fail(exception.getMessage());
110+
}
111+
}
112+
113+
89114
// 通过 TransferManager 分片上传,返回 CompleteMultiUploadResult
90115
@Test public void transferManagerUploadPic() {
91116

QCloudCosXml/cosxml/src/androidTest/java/com/tencent/cos/xml/model/object/ObjectTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ public void testAsync() {
6464
adapter.testSyncRequest();
6565
}
6666
}
67+
68+
@Test public void testGetSnapshot() {
69+
70+
71+
}
6772
}

0 commit comments

Comments
 (0)