From aa5fe972e19e46331f005d91dcbb04cdf37c87b7 Mon Sep 17 00:00:00 2001 From: yanglu19 Date: Mon, 19 Jun 2023 10:09:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BF=E9=97=AEurl=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?x-bce-security-token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/bos_client.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f1ee219..2520302 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@baiducloud/sdk", - "version": "1.0.0-rc.39", + "version": "1.0.0-rc.40", "description": "Baidu Cloud Engine JavaScript SDK", "main": "./index.js", "browser": { diff --git a/src/bos_client.js b/src/bos_client.js index 96ddd2b..7fe51de 100644 --- a/src/bos_client.js +++ b/src/bos_client.js @@ -106,15 +106,17 @@ BosClient.prototype.generatePresignedUrl = function (bucketName, key, timestamp, var credentials = config.credentials; var auth = new Auth(credentials.ak, credentials.sk); + + if (config.sessionToken) { + params['x-bce-security-token'] = config.sessionToken; + } + var authorization = auth.generateAuthorization( 'GET', resource, params, headers, timestamp, expirationInSeconds, headersToSign); params.authorization = authorization; - if (config.sessionToken) { - params['x-bce-security-token'] = config.sessionToken; - } return util.format('%s%s?%s', config.endpoint, resource, qs.encode(params)); }; @@ -1673,7 +1675,6 @@ BosClient.prototype.sendHTTPRequest = function (httpMethod, resource, args, conf function doRequest() { var agent = this._httpAgent = new HttpClient(config); - var httpContext = { httpMethod: httpMethod, resource: resource,