cos-wx-sdk-v5 1.7.0 → 1.7.2

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.7.1](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.7.0...v1.7.1) - 2024-06-12
11
+
12
+ feat
13
+ - 支持万象智能检索接口
14
+
15
+ ### Merged
16
+
17
+ - Dev/1.7.1 [`#104`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/104)
18
+
19
+ ### Commits
20
+
21
+ - Updated CHANGELOG.md [`c882649`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/c8826499f7b806b16fefa749b52e50d51a947049)
22
+
23
+ ## [v1.7.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.6.2...v1.7.0) - 2024-05-27
24
+
25
+ feat
26
+ - getObject 新增对 Key 校验
27
+
28
+ ### Merged
29
+
30
+ - feat: 1.7.0 [`#103`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/103)
31
+
32
+ ### Commits
33
+
34
+ - Updated CHANGELOG.md [`8c61b5d`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/8c61b5dc4d38bbe7e9aab0c28748a67a4e61c05b)
35
+
10
36
  ## [v1.6.2](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.6.1...v1.6.2) - 2024-04-16
11
37
 
12
38
  feat
@@ -390,10 +416,6 @@ fix:CIHost兼容处理
390
416
 
391
417
  ## [v1.1.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.0.13...v1.1.0) - 2021-11-17
392
418
 
393
- - 新增appendObject接口
394
- - 新增媒体处理demo
395
- - 修复已知d.ts错误
396
-
397
419
  ### Merged
398
420
 
399
421
  - Feat/1.1.0 [`#55`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/55)
@@ -415,8 +437,6 @@ fix:CIHost兼容处理
415
437
 
416
438
  ## [v1.0.13](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.0.12...v1.0.13) - 2021-11-11
417
439
 
418
- fix:修复uploadSliceItem
419
-
420
440
  ### Commits
421
441
 
422
442
  - Updated CHANGELOG.md [`6c52c38`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/6c52c382a2e5ff5edf346fb94869b67097f6f9dc)
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  由于签名计算放在前端会暴露 SecretId 和 SecretKey,我们把签名计算过程放在后端实现,前端通过 ajax 向后端获取签名结果,正式部署时请再后端加一层自己网站本身的权限检验。
13
13
 
14
- 这里提供 [PHP 和 NodeJS 的签名例子](https://github.com/tencentyun/cos-js-sdk-v5/blob/master/server/),其他语言,请参照对应的 [XML SDK](https://cloud.tencent.com/document/product/436/6474)
14
+ 这里提供 [NodeJS 的签名示例](https://github.com/tencentyun/cos-js-sdk-v5/blob/master/server/),其他语言,请参照对应的 [XML SDK](https://cloud.tencent.com/document/product/436/6474)
15
15
 
16
16
  ### 三、上传例子
17
17
 
@@ -26,29 +26,42 @@ var Bucket = 'test-1250000000';
26
26
  var Region = 'ap-guangzhou';
27
27
 
28
28
  // 初始化实例
29
- var cos = new COS({
29
+ const cos = new COS({
30
+ SimpleUploadMethod: 'putObject', // 强烈建议,高级上传、批量上传内部对小文件做简单上传时使用putObject,sdk版本至少需要v1.3.0
30
31
  getAuthorization: function (options, callback) {
31
- // 异步获取签名
32
+ // 初始化时不会调用,只有调用 cos 方法(例如 cos.putObject)时才会进入
33
+ // 异步获取临时密钥
34
+ // 服务端 JS 示例:https://github.com/tencentyun/cos-js-sdk-v5/blob/master/server/
35
+ // 服务端其他语言参考 COS STS SDK :https://github.com/tencentyun/qcloud-cos-sts-sdk
36
+ // STS 详细文档指引看:https://cloud.tencent.com/document/product/436/14048
32
37
  wx.request({
33
- url: 'https://example.com/sts.php', // 步骤二提供的签名接口
38
+ url: 'https://example.com/server/sts', // url 替换成您自己的后端服务
34
39
  data: {
35
- Method: options.Method,
36
- Key: options.Key
40
+ bucket: options.Bucket,
41
+ region: options.Region,
37
42
  },
38
- dataType: 'text',
43
+ dataType: 'json',
39
44
  success: function (result) {
40
- var data = result.data;
45
+ const data = result.data;
46
+ const credentials = data && data.credentials;
47
+ if (!data || !credentials) return console.error('credentials invalid');
48
+ // 检查credentials格式
49
+ console.log(credentials);
41
50
  callback({
42
- TmpSecretId: data.credentials && data.credentials.tmpSecretId,
43
- TmpSecretKey: data.credentials && data.credentials.tmpSecretKey,
44
- XCosSecurityToken: data.credentials && data.credentials.sessionToken,
45
- ExpiredTime: data.expiredTime,
51
+ TmpSecretId: credentials.tmpSecretId,
52
+ TmpSecretKey: credentials.tmpSecretKey,
53
+ // v1.2.0之前版本的 SDK 使用 XCosSecurityToken 而不是 SecurityToken
54
+ SecurityToken: credentials.sessionToken,
55
+ // 建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
56
+ StartTime: data.startTime, // 时间戳,单位秒,如:1580000000
57
+ ExpiredTime: data.expiredTime, // 时间戳,单位秒,如:1580000900
46
58
  });
47
59
  }
48
60
  });
49
61
  }
50
62
  });
51
63
 
64
+
52
65
  // 选择文件
53
66
  wx.chooseImage({
54
67
  count: 1, // 默认9
@@ -71,7 +71,7 @@ function getSnapshot() {
71
71
  },
72
72
  function (err, data) {
73
73
  if (err) {
74
- console.log('请求出错');
74
+ console.log(err);
75
75
  } else {
76
76
  const imgBase64 = wx.arrayBufferToBase64(data.Body);
77
77
  console.log(imgBase64);