Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanqin committed Nov 28, 2024
1 parent acd2c24 commit cc41595
Show file tree
Hide file tree
Showing 151 changed files with 561 additions and 366 deletions.
4 changes: 2 additions & 2 deletions AppScope/app.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"app": {
"bundleName": "com.tencent.cloud.cos",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"versionCode": 1010100,
"versionName": "1.1.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
Expand Down
2 changes: 1 addition & 1 deletion cosSdk/BuildProfile.ets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const HAR_VERSION = '1.1.0';
export const BUILD_MODE_NAME = 'release';
export const DEBUG = false;
export const TARGET_NAME = 'default';
Expand Down
4 changes: 4 additions & 0 deletions cosSdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
## 1.1.0
- 更换http网络库到rcp
- http重定向默认不开启

## 1.0.0
- 发布对外正式版本
2 changes: 1 addition & 1 deletion cosSdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
``` bash
"dependencies": {
...
"@tencentcloud/cos":"1.0.0"
"@tencentcloud/cos":"1.1.0"
}
```
2. SDK 需要网络权限,用于与 COS 服务器进行通信,请在应用模块下的 module.json5 中添加如下权限声明:
Expand Down
Binary file removed cosSdk/foundation100.har
Binary file not shown.
Binary file added cosSdk/foundation110.har
Binary file not shown.
8 changes: 4 additions & 4 deletions cosSdk/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cosSdk/oh-package.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tencentcloud/cos",
"version": "1.0.0",
"version": "1.1.0",
"description": "Tencent cloud cos sdk",
"main": "Index.ets",
"keywords": ["对象存储", "COS", "腾讯云"],
Expand All @@ -9,7 +9,7 @@
"author": "Cos",
"license": "Apache-2.0",
"dependencies": {
"@tencentcloud/foundation": "file:./foundation100.har"
// "foundation": "file:../foundation"
"@tencentcloud/foundation": "file:./foundation110.har"
// "@tencentcloud/foundation": "file:../foundation"
}
}
7 changes: 4 additions & 3 deletions cosSdk/src/main/ets/CosXmlBaseService.ets
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class CosXmlBaseService {
let qcloudHttpRequest = new QCloudHttpRequest<T2>(
cosXmlRequest.getMethod(),
this.cosXmlServiceConfig.protocol,
this.cosXmlServiceConfig.getRequestHost(cosXmlRequest.bucket),
this.cosXmlServiceConfig.getRequestHost(cosXmlRequest.bucket, cosXmlRequest.region),
this.cosXmlServiceConfig.port,
cosXmlRequest.getPath(this.cosXmlServiceConfig),
cosXmlRequest.getBodySerializer(),
Expand All @@ -195,7 +195,8 @@ export class CosXmlBaseService {
...Array.from(this.cosXmlServiceConfig.headers.entries())]),
cosXmlRequest.getQueries(),
cosXmlRequest.isNeedMD5,
cosXmlRequest.isSignedInURL
cosXmlRequest.isSignedInURL,
this.cosXmlServiceConfig.requestConfiguration
);
qcloudHttpRequest.noSignHeaderKeys =
new Set(Array.from(cosXmlRequest.noSignHeaderKeys).concat(Array.from(this.cosXmlServiceConfig.noSignHeaderKeys)));
Expand Down Expand Up @@ -378,7 +379,7 @@ export class CosXmlBaseService {

public getAccessUrl(request: CosXmlRequest): string {
let url =
`${this.cosXmlServiceConfig.protocol}://${this.cosXmlServiceConfig.getRequestHost(request.bucket)}/${request.getPath(this.cosXmlServiceConfig)}`;
`${this.cosXmlServiceConfig.protocol}://${this.cosXmlServiceConfig.getRequestHost(request.bucket, request.region)}/${request.getPath(this.cosXmlServiceConfig)}`;
return url;
}
}
34 changes: 26 additions & 8 deletions cosSdk/src/main/ets/CosXmlServiceConfig.ets
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { rcp } from "@kit.RemoteCommunicationKit";
import { CosInvalidArgumentError } from "./error/CosInvalidArgumentError";

export class CosXmlServiceConfig {

Expand Down Expand Up @@ -41,6 +43,11 @@ export class CosXmlServiceConfig {
*/
dnsServers: Array<string> | undefined;

/**
* 网络高级配置
* 具体请参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/remote-communication-rcp-V5#section1898141153617
*/
requestConfiguration?: rcp.Configuration;
/**
* 设置公共header
*/
Expand Down Expand Up @@ -85,16 +92,27 @@ export class CosXmlServiceConfig {
this.region = region;
}

getRequestHost(bucket: string|undefined): string {
if(!this.region){
getRequestHost(bucket: string|undefined, region: string|undefined): string {
let finalRegion = region;
if(!finalRegion){
finalRegion = this.region;
}

if(!finalRegion){
return this.host;
} else {
return this.host.replace("${bucket}", bucket!).replace("${region}", this.region);
// if(bucket){
// return this.host.replace("${bucket}", bucket).replace("${region}", this.region);
// } else {
// return "service.cos.myqcloud.com";
// }
if(bucket){
const regex = /^[a-zA-Z0-9.-]*$/;
if (!regex.test(bucket)) {
throw new CosInvalidArgumentError('bucket contains illegal character! It can only contains a-z, A-Z, 0-9, . and -');
}
if (!regex.test(finalRegion)) {
throw new CosInvalidArgumentError('region contains illegal character! It can only contains a-z, A-Z, 0-9, . and -');
}
return this.host.replace("${bucket}", bucket).replace("${region}", finalRegion);
} else {
return "service.cos.myqcloud.com";
}
}
}
}
2 changes: 1 addition & 1 deletion cosSdk/src/ohosTest/ets/test/transfer/Upload.test.ets
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TestConst } from '../common/TestConst';
import { TestUtils } from '../common/TestUtils';
import { ArrayList } from '@kit.ArkTS';
import { Credential } from '../common/Credential';
import { HttpHeader } from 'foundation';
import { HttpHeader } from '@tencentcloud/foundation';

export default function uploadTest(cosXmlBaseService: CosXmlBaseService) {
describe('uploadTest', () => {
Expand Down
Binary file removed cosTransferPractice/cosSdk-1.0.0.har
Binary file not shown.
Binary file added cosTransferPractice/cosSdk-1.1.0.har
Binary file not shown.
21 changes: 10 additions & 11 deletions cosTransferPractice/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cosTransferPractice/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"license": "",
"dependencies": {
// "@tencentcloud/cos": "file:../cosSdk"
// "@tencentcloud/cos": "file:./cosSdk-1.0.0.har"
"@tencentcloud/cos": "^1.0.0"
"@tencentcloud/cos": "file:./cosSdk-1.1.0.har"
// "@tencentcloud/cos": "^1.1.0"
},
"devDependencies": {},
"dynamicDependencies": {}
Expand Down
80 changes: 43 additions & 37 deletions cosTransferPractice/src/main/ets/pages/download_page/Index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { printError, sizeFormat } from '../../utils/Utils';
@Entry
@Component
export struct DownloadPage {
@State filePath:string = getContext().filesDir + '/video.mp4';
@State filePath:string = getContext().filesDir + '/test_video.mp4';
@State total:number = 0;
@State value:number = 0;
@State result:string = '';
Expand All @@ -20,47 +20,53 @@ export struct DownloadPage {
}

_downloadFile(){
this.reset();
this.pause = false;
let now = new Date().getTime() / 1000;
let getRequest = new GetObjectRequest(Const.TEST_BUCKET, Const.TEST_DOWNLOAD_PATH, this.filePath);
let task:DownloadTask = CosXmlBaseService.default().download(getRequest);
task.onProgress = (progress:HttpProgress)=>{
Logger.debug(`qqq total=${progress.target} complete=${progress.complete}`)
this.total = progress.target;
this.value = progress.complete;
};
task.onResult = {
onSuccess:async (request, result)=>{
this.currentTask = undefined;

// crc64计算比较慢,大文件不太适合
// let fileHash = (await CRC64.crc64File(this.filePath)).toString();
// let crc64ecma: string = "";
// if(result.headers){
// crc64ecma = result.headers["x-cos-hash-crc64ecma"];
// }
// Logger.info(`crc64:本地文件crc64为${fileHash} x-cos-hash-crc64ecma为${crc64ecma}`)
// if(fileHash === crc64ecma) {
// let finish = new Date().getTime() / 1000;
// this.result = '下载成功\n' + '下载平均速度:' + sizeFormat(this.total/((finish - now) || 1)) + '/S\n' + 'result\n' + JSON.stringify(result,null,2) + '\n';
// this.pause = true;
// } else {
// this.result = `下载失败:crc64校验失败`
// }
try {
this.reset();
this.pause = false;
let now = new Date().getTime() / 1000;
let getRequest = new GetObjectRequest(Const.TEST_BUCKET, Const.TEST_DOWNLOAD_PATH, this.filePath);
let task:DownloadTask = CosXmlBaseService.default().download(getRequest);
task.onProgress = (progress:HttpProgress)=>{
Logger.debug(`qqq total=${progress.target} complete=${progress.complete}`)
this.total = progress.target;
this.value = progress.complete;
};
task.onResult = {
onSuccess:async (request, result)=>{
this.currentTask = undefined;

let finish = new Date().getTime() / 1000;
this.result = '下载成功\n' + '下载平均速度:' + sizeFormat(this.total/((finish - now) || 1)) + '/S\n' + 'result\n' + JSON.stringify(result,null,2) + '\n';
this.pause = true;
},
onFail:(request, error)=>{
this.result = `下载失败:
// crc64计算比较慢,大文件不太适合
// let fileHash = (await CRC64.crc64File(this.filePath)).toString();
// let crc64ecma: string = "";
// if(result.headers){
// crc64ecma = result.headers["x-cos-hash-crc64ecma"];
// }
// Logger.info(`crc64:本地文件crc64为${fileHash} x-cos-hash-crc64ecma为${crc64ecma}`)
// if(fileHash === crc64ecma) {
// let finish = new Date().getTime() / 1000;
// this.result = '下载成功\n' + '下载平均速度:' + sizeFormat(this.total/((finish - now) || 1)) + '/S\n' + 'result\n' + JSON.stringify(result,null,2) + '\n';
// this.pause = true;
// } else {
// this.result = `下载失败:crc64校验失败`
// }

let finish = new Date().getTime() / 1000;
this.result = '下载成功\n' + '下载平均速度:' + sizeFormat(this.total/((finish - now) || 1)) + '/S\n' + 'result\n' + JSON.stringify(result,null,2) + '\n';
this.pause = true;
},
onFail:(request, error)=>{
this.result = `下载失败:
${printError(error)}`;
}
}
task.start();
this.result = "开始下载";
this.currentTask = task;
} catch (e) {
console.log(e)
}
task.start();
this.result = "开始下载";
this.currentTask = task;

}

scroller: Scroller = new Scroller()
Expand Down
2 changes: 1 addition & 1 deletion foundation/BuildProfile.ets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const HAR_VERSION = '1.1.0';
export const BUILD_MODE_NAME = 'release';
export const DEBUG = false;
export const TARGET_NAME = 'default';
Expand Down
2 changes: 1 addition & 1 deletion foundation/oh-package.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tencentcloud/foundation",
"version": "1.0.0",
"version": "1.1.0",
"description": "Tencent cloud cos sdk basic library",
"main": "Index.ets",
"author": "Cos",
Expand Down
Loading

0 comments on commit cc41595

Please sign in to comment.