From 5cd743ec07684adc0a265af7cb7362d6b750ab79 Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Tue, 16 Oct 2018 11:33:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demo.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index 1c7f62c..59ec873 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -135,17 +135,6 @@ var logger = { }, }; -function getAuth() { - var key = '1.png'; - cos.options.getAuthorization({ - Method: 'get', - Key: key - }, function (auth) { - // 注意:这里的 Bucket 格式是 test-1250000000 - logger.log('http://' + config.Bucket + '.cos.' + config.Region + '.myqcloud.com' + '/' + encodeURIComponent(key).replace(/%2F/g, '/') + '?sign=' + encodeURIComponent(auth)); - }); -} - function getObjectUrl() { var url = cos.getObjectUrl({ Bucket: config.Bucket, // Bucket 格式:test-1250000000 @@ -159,6 +148,18 @@ function getObjectUrl() { logger.log(url); } +function getAuth() { + var key = '1.png'; + // 这里不推荐自己拼接,推荐使用 getObjectUrl 获取 url + cos.options.getAuthorization({ + Method: 'get', + Key: key + }, function (auth) { + // 注意:这里的 Bucket 格式是 test-1250000000 + logger.log('http://' + config.Bucket + '.cos.' + config.Region + '.myqcloud.com' + '/' + encodeURIComponent(key).replace(/%2F/g, '/') + '?sign=' + encodeURIComponent(auth)); + }); +} + function getBucket() { cos.getBucket({ Bucket: config.Bucket, // Bucket 格式:test-1250000000 @@ -769,8 +770,8 @@ function sliceCopyFile() { (function () { var list = [ // 'getService', // 不支持 - 'getAuth', 'getObjectUrl', + 'getAuth', // 'putBucket', // 不支持 'getBucket', 'headBucket',