Skip to content

Commit be859ab

Browse files
authored
Merge pull request #131 from livehigh/feat/1.3.2
Feat/1.3.2
2 parents ee9f20c + e9346c0 commit be859ab

File tree

12 files changed

+215
-9856
lines changed

12 files changed

+215
-9856
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
### 一、前期准备
1010

1111
1. 首先,JS SDK 需要浏览器支持基本的 HTML5 特性,以便支持 ajax 上传文件和计算文件 md5 值。
12-
2.[COS对象存储控制台](https://console.cloud.tencent.com/cos) 创建存储桶,得到 Bucket(存储桶名称) 和 [Region(地域名称)](https://cloud.tencent.com/document/product/436/6224)
12+
2.[COS对象存储控制台](https://console.cloud.tencent.com/cos) 创建存储桶,得到 Bucket(由bucketname-appid 组成,appid必须填入) 和 [Region(地域名称)](https://cloud.tencent.com/document/product/436/6224)
1313
3.[控制台密钥管理](https://console.cloud.tencent.com/capi) 获取您的项目 SecretId 和 SecretKey
1414
4. 配置 CORS 规则,配置例子如下图:
1515

@@ -31,7 +31,11 @@
3131
<input id="file-selector" type="file">
3232
<script src="dist/cos-js-sdk-v5.min.js"></script>
3333
<script>
34+
35+
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.cloud.tencent.com/cos5/bucket
3436
var Bucket = 'test-1250000000';
37+
// 存储桶Region可以在COS控制台指定存储桶的概览页查看 https://console.cloud.tencent.com/cos5/bucket/
38+
// 关于地域的详情见 https://cloud.tencent.com/document/product/436/6224
3539
var Region = 'ap-guangzhou';
3640
3741
// 初始化实例

demo/common/cos-auth.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,14 @@
9292
});
9393
};
9494

95-
var obj2str = function (obj) {
95+
var obj2str = function (obj, lowerCaseKey) {
9696
var i, key, val;
9797
var list = [];
9898
var keyList = getObjectKeys(obj);
9999
for (i = 0; i < keyList.length; i++) {
100100
key = keyList[i];
101101
val = (obj[key] === undefined || obj[key] === null) ? '' : ('' + obj[key]);
102-
key = key.toLowerCase();
103-
key = camSafeUrlEncode(key);
102+
key = lowerCaseKey? camSafeUrlEncode(key).toLowerCase() : camSafeUrlEncode(key);
104103
val = camSafeUrlEncode(val) || '';
105104
list.push(key + '=' + val)
106105
}
@@ -124,7 +123,7 @@
124123
var signKey = CryptoJS.HmacSHA1(qKeyTime, SecretKey).toString();
125124

126125
// 步骤二:构成 FormatString
127-
var formatString = [method, pathname, obj2str(query), obj2str(headers), ''].join('\n');
126+
var formatString = [method, pathname, obj2str(query, true), obj2str(headers, true), ''].join('\n');
128127

129128
// 步骤三:计算 StringToSign
130129
var stringToSign = ['sha1', qSignTime, CryptoJS.SHA1(formatString).toString(), ''].join('\n');

demo/common/cos-auth.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)