From 7e823bbaf631e3e7002bddc519c4989f7f7307eb Mon Sep 17 00:00:00 2001 From: wonderswang Date: Tue, 27 Apr 2021 15:37:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20getAuthorization=20=E5=87=BA?= =?UTF-8?q?=E9=94=99=E6=97=B6=E8=83=BD=E6=8A=8A=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E5=9C=A8=E8=BE=93=E5=85=A5=E6=A1=86=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demo.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index 9d5d0b6..db92eb6 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -58,7 +58,9 @@ var getAuthorization = function (options, callback) { var credentials = data.credentials; } catch (e) { } - if (!data || !credentials) return console.error('credentials invalid'); + if (!data || !credentials) { + return logger.error('credentials invalid:\n' + JSON.stringify(data, null, 2)) + }; var authorization = COS.getAuthorization({ SecretId: credentials.tmpSecretId, // 可传固定密钥或者临时密钥 SecretKey: credentials.tmpSecretKey, // 可传固定密钥或者临时密钥 @@ -89,7 +91,9 @@ var getAuthorization = function (options, callback) { // var credentials = data.credentials; // } catch (e) { // } - // if (!data || !credentials) return console.error('credentials invalid'); + // if (!data || !credentials) { + // return logger.error('credentials invalid:\n' + JSON.stringify(data, null, 2)) + // }; // callback({ // TmpSecretId: credentials.tmpSecretId, // TmpSecretKey: credentials.tmpSecretKey, @@ -936,7 +940,7 @@ function getObject() { Bucket: config.Bucket, // Bucket 格式:test-1250000000 Region: config.Region, onProgress: function (progressData) { - console.log(JSON.stringify(progressData)); + logger.log(JSON.stringify(progressData)); } }, function (err, data) { logger.log(err || data); @@ -1397,8 +1401,7 @@ function request() { Query: {}, Body: '', }, function (err, data) { - console.log('err:', err); - console.log('data:', data); + logger.log(err || data); }); } From b0f12c1b5f2dd7756af2de4ec1e9501dbcfc1301 Mon Sep 17 00:00:00 2001 From: wonderswang Date: Tue, 27 Apr 2021 15:48:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20getAuth=20?= =?UTF-8?q?=E9=87=8C=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/demo.js b/demo/demo.js index db92eb6..b8c9850 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -220,7 +220,7 @@ function getAuth() { Key: key }, function (AuthData) { if (typeof AuthData === 'string') { - AuthData = {Authorization: AuthData.Authorization}; + AuthData = {Authorization: AuthData}; } var url = 'http://' + config.Bucket + '.cos.' + config.Region + '.myqcloud.com' + '/' + camSafeUrlEncode(key).replace(/%2F/g, '/') + From bce7d0e26b91bee4deb8968c789df3ef0bcef3e9 Mon Sep 17 00:00:00 2001 From: wonderswang Date: Tue, 27 Apr 2021 16:56:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20demo.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demo.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index b8c9850..639dbdf 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -939,6 +939,7 @@ function getObject() { cos.getObject({ Bucket: config.Bucket, // Bucket 格式:test-1250000000 Region: config.Region, + Key: '1mb.zip', onProgress: function (progressData) { logger.log(JSON.stringify(progressData)); } @@ -1394,12 +1395,13 @@ function request() { cos.request({ Bucket: config.Bucket, Region: config.Region, - Key: '1.txt', - Method: 'GET', - Action: 'acl', - Headers: {}, - Query: {}, - Body: '', + Key: '1.png', + Method: 'POST', + Action: 'image_process', + Headers: { + // 通过 imageMogr2 接口使用图片缩放功能:指定图片宽度为 200,宽度等比压缩 + 'Pic-Operations': '{"is_pic_info": 1, "rules": [{"fileid": "desample_photo.jpg", "rule": "imageMogr2/thumbnail/200x/"}]}' + }, }, function (err, data) { logger.log(err || data); });