cos-wx-sdk-v5 1.4.7 → 1.4.9

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,32 @@ 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.8](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.7...v1.4.8) - 2022-11-21
11
+
12
+ feat
13
+ - getObjectAcl支持传VersionId
14
+
15
+ ### Merged
16
+
17
+ - feat: getObjectAcl支持VersionId [`#81`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/81)
18
+
19
+ ### Commits
20
+
21
+ - Updated CHANGELOG.md [`8dc585a`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/8dc585a2b6c2c31084fc5952ccc29d942282e031)
22
+
23
+ ## [v1.4.7](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.6...v1.4.7) - 2022-11-09
24
+
25
+ fix
26
+ - 升级依赖包@xmldom/xmldom版本
27
+
28
+ ### Merged
29
+
30
+ - fix: update @xmldom [`#80`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/80)
31
+
32
+ ### Commits
33
+
34
+ - Updated CHANGELOG.md [`60ad375`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/60ad37542e472d0d6f1f3eaa7dc7487c4c9890d6)
35
+
10
36
  ## [v1.4.6](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.5...v1.4.6) - 2022-10-25
11
37
 
12
38
  fix
@@ -435,10 +461,6 @@ const 改为 var
435
461
 
436
462
  ## [v0.5.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v0.4.0...v0.5.0) - 2018-04-26
437
463
 
438
- * 修改签名样例,改成临时密钥形式,通过临时密钥的 Policy,更好地在后端控制权限
439
- * 修复 DOMParser 在手机小程序环境里报错问题
440
- * 优化 demo,只使用上传功能推荐用代码片段,不使用完整 SDK
441
-
442
464
  ### Commits
443
465
 
444
466
  - 修复 content-type 出错问题 [`a6387a4`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/a6387a429bc94ed150c9ae09b4b9dd9c890e4c78)
@@ -454,11 +476,6 @@ const 改为 var
454
476
 
455
477
  ## v0.4.0 - 2018-01-12
456
478
 
457
- * 完成功能完整的版本
458
- * 支持最大上传5GB
459
- * 支持取消上传、上传进度
460
- * 修复手机使用错误
461
-
462
479
  ### Commits
463
480
 
464
481
  - init [`294a9a9`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/294a9a9298d330e9f56da5480643a2137703007d)
@@ -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.7\",\"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.9\",\"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
 
@@ -10705,6 +10705,12 @@ function deleteObject(params, callback) {
10705
10705
 
10706
10706
 
10707
10707
  function getObjectAcl(params, callback) {
10708
+ var reqParams = {};
10709
+
10710
+ if (params.VersionId) {
10711
+ reqParams.versionId = params.VersionId;
10712
+ }
10713
+
10708
10714
  submitRequest.call(this, {
10709
10715
  Action: 'name/cos:GetObjectACL',
10710
10716
  method: 'GET',
@@ -10712,6 +10718,7 @@ function getObjectAcl(params, callback) {
10712
10718
  Region: params.Region,
10713
10719
  Key: params.Key,
10714
10720
  headers: params.Headers,
10721
+ qs: reqParams,
10715
10722
  action: 'acl'
10716
10723
  }, function (err, data) {
10717
10724
  if (err) return callback(err);
@@ -13582,7 +13589,7 @@ var obj2str = function obj2str(obj, lowerCaseKey) {
13582
13589
  }; // 可以签入签名的headers
13583
13590
 
13584
13591
 
13585
- 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'];
13592
+ 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'];
13586
13593
 
13587
13594
  var getSignHeaderObj = function getSignHeaderObj(headers) {
13588
13595
  var signHeaderObj = {};