Skip to content

Commit

Permalink
fix cos_client
Browse files Browse the repository at this point in the history
  • Loading branch information
dfounderliu committed Feb 7, 2020
1 parent 50936a7 commit 3fe4911
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 变更历史


## 2020-02-06
* 优化COS实例创建代码

## 2020-02-06
* 修复rollback操作可能出现函数状态错误问题
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-tencent-scf",
"version": "0.1.34",
"version": "0.1.35",
"description": "Provider plugin for the Serverless Framework v1.x which adds support for Tencent Cloud Functions.",
"main": "index.js",
"author": "Tencent Cloud, Inc.",
Expand Down
30 changes: 10 additions & 20 deletions shared/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const MonitorClinet = tencentcloud.monitor.v20180724.Client

class AbstractHandler {
constructor(options, serverless) {

const { credentials, region } = options
const { tencent_appid, tencent_secret_id, tencent_secret_key } = credentials
this.options = options
Expand Down Expand Up @@ -98,26 +97,17 @@ class AbstractHandler {
const chunkSize = options.chunkSize || 1024 * 1024 * 8
const timeout = options.timeout || 120

if (!options.token) {
return new tencentcloudCos({
SecretId: secret_id,
SecretKey: secret_key,
FileParallelLimit: fileParallelLimit,
ChunkParallelLimit: chunkParallelLimit,
ChunkSize: chunkSize,
Timeout: timeout * 1000
})
}

return new tencentcloudCos({
getAuthorization: function(option, callback) {
callback({
TmpSecretId: secret_id,
TmpSecretKey: secret_key,
XCosSecurityToken: options.token,
ExpiredTime: options.timestamp
})
}
SecretId: secret_id,
SecretKey: secret_key,
FileParallelLimit: fileParallelLimit,
ChunkParallelLimit: chunkParallelLimit,
ChunkSize: chunkSize,
Timeout: timeout * 1000,
TmpSecretId: secret_id,
TmpSecretKey: secret_key,
XCosSecurityToken: options.token,
ExpiredTime: options.timestamp
})
}

Expand Down

0 comments on commit 3fe4911

Please sign in to comment.