Skip to content

Commit

Permalink
修改 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Oct 16, 2018
1 parent e4d43c3 commit 5cd743e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -769,8 +770,8 @@ function sliceCopyFile() {
(function () {
var list = [
// 'getService', // 不支持
'getAuth',
'getObjectUrl',
'getAuth',
// 'putBucket', // 不支持
'getBucket',
'headBucket',
Expand Down

0 comments on commit 5cd743e

Please sign in to comment.