cos-wx-sdk-v5 1.4.8 → 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,19 @@ 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
+
10
23
  ## [v1.4.7](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.6...v1.4.7) - 2022-11-09
11
24
 
12
25
  fix
@@ -448,10 +461,6 @@ const 改为 var
448
461
 
449
462
  ## [v0.5.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v0.4.0...v0.5.0) - 2018-04-26
450
463
 
451
- * 修改签名样例,改成临时密钥形式,通过临时密钥的 Policy,更好地在后端控制权限
452
- * 修复 DOMParser 在手机小程序环境里报错问题
453
- * 优化 demo,只使用上传功能推荐用代码片段,不使用完整 SDK
454
-
455
464
  ### Commits
456
465
 
457
466
  - 修复 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.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
 
@@ -13589,7 +13589,7 @@ var obj2str = function obj2str(obj, lowerCaseKey) {
13589
13589
  }; // 可以签入签名的headers
13590
13590
 
13591
13591
 
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'];
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'];
13593
13593
 
13594
13594
  var getSignHeaderObj = function getSignHeaderObj(headers) {
13595
13595
  var signHeaderObj = {};