cos-wx-sdk-v5 1.4.8 → 1.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
9
9
 
10
+ ## [v1.4.9](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.8...v1.4.9) - 2022-12-29
11
+
12
+ fix
13
+ - 更新可以签入签名的headers
14
+
15
+ ### Merged
16
+
17
+ - fix: 更新可以签入签名的headers [`#83`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/83)
18
+
19
+ ### Commits
20
+
21
+ - 更新简单上传示例 [`18d1a02`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/18d1a02050a431d4015c28e8e7ed816a0c1e4f2a)
22
+ - Updated CHANGELOG.md [`51e4040`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/51e40408d0c57fe9571507369a470a8668244ff5)
23
+ - upd: sts demo补充condition指引 [`658b3eb`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/658b3eba99c9432f11dfa411a262f546f5a22f6c)
24
+ - 更新简单上传示例 [`ce26017`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/ce26017790129e4e43f0a296558113d3f65b6f9c)
25
+
26
+ ## [v1.4.8](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.7...v1.4.8) - 2022-11-21
27
+
28
+ feat
29
+ - getObjectAcl支持传VersionId
30
+
31
+ ### Merged
32
+
33
+ - feat: getObjectAcl支持VersionId [`#81`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/81)
34
+
35
+ ### Commits
36
+
37
+ - Updated CHANGELOG.md [`8dc585a`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/8dc585a2b6c2c31084fc5952ccc29d942282e031)
38
+
10
39
  ## [v1.4.7](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.6...v1.4.7) - 2022-11-09
11
40
 
12
41
  fix
@@ -448,10 +477,6 @@ const 改为 var
448
477
 
449
478
  ## [v0.5.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v0.4.0...v0.5.0) - 2018-04-26
450
479
 
451
- * 修改签名样例,改成临时密钥形式,通过临时密钥的 Policy,更好地在后端控制权限
452
- * 修复 DOMParser 在手机小程序环境里报错问题
453
- * 优化 demo,只使用上传功能推荐用代码片段,不使用完整 SDK
454
-
455
480
  ### Commits
456
481
 
457
482
  - 修复 content-type 出错问题 [`a6387a4`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/a6387a429bc94ed150c9ae09b4b9dd9c890e4c78)
@@ -1,9 +1,6 @@
1
1
  var config = require('./config');
2
2
 
3
3
  var uploadFile = function () {
4
- // 请求用到的参数
5
- // var prefix = 'https://cos.' + config.Region + '.myqcloud.com/' + config.Bucket + '/'; // 这个是后缀式,签名也要指定 Pathname: '/' + config.Bucket + '/'
6
- var prefix = 'https://' + config.Bucket + '.cos.' + config.Region + '.myqcloud.com/';
7
4
 
8
5
  // 对更多字符编码的 url encode 格式
9
6
  var camSafeUrlEncode = function (str) {
@@ -19,7 +16,7 @@ var uploadFile = function () {
19
16
  var getCredentials = function (options, callback) {
20
17
  wx.request({
21
18
  method: 'GET',
22
- url: 'http://127.0.0.1:3000/post-policy?key=' + encodeURIComponent(options.Key), // 服务端签名,参考 server 目录下的两个签名例子
19
+ url: 'http://127.0.0.1:3000/post-policy?ext=' + options.ext, // 服务端签名,参考 server 目录下的两个签名例子
23
20
  dataType: 'json',
24
21
  success: function (result) {
25
22
  var data = result.data;
@@ -37,10 +34,15 @@ var uploadFile = function () {
37
34
 
38
35
  // 上传文件
39
36
  var uploadFile = function (filePath) {
40
- var Key = filePath.substr(filePath.lastIndexOf('/') + 1); // 这里指定上传的文件名
41
- getCredentials({Key: Key}, function (credentials) {
37
+ var extIndex = filePath.lastIndexOf('.');
38
+ var fileExt = extIndex >= -1 ? filePath.substr(extIndex + 1) : '';
39
+ getCredentials({ext: fileExt}, function (credentials) {
40
+ // 请求用到的参数
41
+ // var prefix = 'https://cos.' + config.Region + '.myqcloud.com/' + config.Bucket + '/'; // 这个是后缀式,签名也要指定 Pathname: '/' + config.Bucket + '/'
42
+ var prefix = 'https://' + credentials.bucket + '.cos.' + credentials.region + '.myqcloud.com/';
43
+ var key = credentials.key; // 让服务端来决定文件名更安全
42
44
  var formData = {
43
- 'key': Key,
45
+ 'key': key,
44
46
  'success_action_status': 200,
45
47
  'Content-Type': '',
46
48
  'q-sign-algorithm': credentials.qSignAlgorithm,
@@ -56,12 +58,13 @@ var uploadFile = function () {
56
58
  filePath: filePath,
57
59
  formData: formData,
58
60
  success: function (res) {
59
- var url = prefix + camSafeUrlEncode(Key).replace(/%2F/g, '/');
61
+ var url = prefix + camSafeUrlEncode(key).replace(/%2F/g, '/');
60
62
  if (res.statusCode === 200) {
61
63
  wx.showModal({title: '上传成功', content: url, showCancel: false});
62
64
  } else {
63
65
  wx.showModal({title: '上传失败', content: JSON.stringify(res), showCancel: false});
64
66
  }
67
+ console.log(res.header['x-cos-request-id']);
65
68
  console.log(res.statusCode);
66
69
  console.log(url);
67
70
  },
@@ -6793,7 +6793,7 @@ module.exports = function(module) {
6793
6793
  /*! exports provided: name, version, description, main, scripts, repository, author, license, dependencies, devDependencies, default */
6794
6794
  /***/ (function(module) {
6795
6795
 
6796
- module.exports = JSON.parse("{\"name\":\"cos-wx-sdk-v5\",\"version\":\"1.4.8\",\"description\":\"小程序 SDK for [腾讯云对象存储服务](https://cloud.tencent.com/product/cos)\",\"main\":\"demo/lib/cos-wx-sdk-v5.min.js\",\"scripts\":{\"dev\":\"cross-env NODE_ENV=development node build.js --mode=development\",\"build\":\"cross-env NODE_ENV=production node build.js --mode=production\",\"sts.js\":\"node server/sts.js\"},\"repository\":{\"type\":\"git\",\"url\":\"http://github.com/tencentyun/cos-wx-sdk-v5.git\"},\"author\":\"carsonxu\",\"license\":\"ISC\",\"dependencies\":{\"mime\":\"^2.4.6\",\"@xmldom/xmldom\":\"^0.8.6\"},\"devDependencies\":{\"@babel/core\":\"7.17.9\",\"babel-loader\":\"8.2.5\",\"@babel/preset-env\":\"7.16.11\",\"body-parser\":\"^1.18.3\",\"cross-env\":\"^7.0.3\",\"express\":\"^4.17.1\",\"qcloud-cos-sts\":\"^3.0.2\",\"terser-webpack-plugin\":\"4.2.3\",\"webpack\":\"4.46.0\",\"webpack-cli\":\"4.10.0\"}}");
6796
+ module.exports = JSON.parse("{\"name\":\"cos-wx-sdk-v5\",\"version\":\"1.4.10\",\"description\":\"小程序 SDK for [腾讯云对象存储服务](https://cloud.tencent.com/product/cos)\",\"main\":\"demo/lib/cos-wx-sdk-v5.min.js\",\"scripts\":{\"dev\":\"cross-env NODE_ENV=development node build.js --mode=development\",\"build\":\"cross-env NODE_ENV=production node build.js --mode=production\",\"sts.js\":\"node server/sts.js\"},\"repository\":{\"type\":\"git\",\"url\":\"http://github.com/tencentyun/cos-wx-sdk-v5.git\"},\"author\":\"carsonxu\",\"license\":\"ISC\",\"dependencies\":{\"mime\":\"^2.4.6\",\"@xmldom/xmldom\":\"^0.8.6\"},\"devDependencies\":{\"@babel/core\":\"7.17.9\",\"babel-loader\":\"8.2.5\",\"@babel/preset-env\":\"7.16.11\",\"body-parser\":\"^1.18.3\",\"cross-env\":\"^7.0.3\",\"express\":\"^4.17.1\",\"qcloud-cos-sts\":\"^3.0.2\",\"terser-webpack-plugin\":\"4.2.3\",\"webpack\":\"4.46.0\",\"webpack-cli\":\"4.10.0\"}}");
6797
6797
 
6798
6798
  /***/ }),
6799
6799
 
@@ -10587,7 +10587,8 @@ function postObject(params, callback) {
10587
10587
  headers['x-cos-grant-full-control'] = params['GrantFullControl'];
10588
10588
  headers['x-cos-storage-class'] = params['StorageClass'];
10589
10589
  headers['x-cos-mime-limit'] = params['MimeLimit'];
10590
- headers['x-cos-traffic-limit'] = params['TrafficLimit']; // SSE-C
10590
+ headers['x-cos-traffic-limit'] = params['TrafficLimit'];
10591
+ headers['x-cos-forbid-overwrite'] = params['ForbidOverwrite']; // SSE-C
10591
10592
 
10592
10593
  headers['x-cos-server-side-encryption-customer-algorithm'] = params['SSECustomerAlgorithm'];
10593
10594
  headers['x-cos-server-side-encryption-customer-key'] = params['SSECustomerKey'];
@@ -13589,7 +13590,7 @@ var obj2str = function obj2str(obj, lowerCaseKey) {
13589
13590
  }; // 可以签入签名的headers
13590
13591
 
13591
13592
 
13592
- var signHeaders = ['content-disposition', 'content-encoding', 'content-length', 'content-md5', 'expect', 'expires', 'host', 'if-match', 'if-modified-since', 'if-none-match', 'if-unmodified-since', 'origin', 'range', 'response-cache-control', 'response-content-disposition', 'response-content-encoding', 'response-content-language', 'response-content-type', 'response-expires', 'transfer-encoding', 'versionid'];
13593
+ var signHeaders = ['cache-control', 'content-disposition', 'content-encoding', 'content-length', 'content-md5', 'expect', 'expires', 'host', 'if-match', 'if-modified-since', 'if-none-match', 'if-unmodified-since', 'origin', 'range', 'transfer-encoding'];
13593
13594
 
13594
13595
  var getSignHeaderObj = function getSignHeaderObj(headers) {
13595
13596
  var signHeaderObj = {};
@@ -13896,6 +13897,7 @@ var formatParams = function formatParams(apiName, params) {
13896
13897
  'x-cos-storage-class': 'StorageClass',
13897
13898
  'x-cos-traffic-limit': 'TrafficLimit',
13898
13899
  'x-cos-mime-limit': 'MimeLimit',
13900
+ 'x-cos-forbid-overwrite': 'ForbidOverwrite',
13899
13901
  // SSE-C
13900
13902
  'x-cos-server-side-encryption-customer-algorithm': 'SSECustomerAlgorithm',
13901
13903
  'x-cos-server-side-encryption-customer-key': 'SSECustomerKey',