cos-wx-sdk-v5 1.4.13 → 1.6.0

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,12 +7,33 @@ 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.12](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.11...v1.4.12) - 2023-08-03
10
+ ## [v1.5.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.12...v1.5.0) - 2024-01-24
11
+
12
+ feat
13
+ 1、提升安全性:不再支持设置 pathStyle
14
+ 2、提升安全性:wx.request 不支持默认redirect
15
+ 3、提升安全性:host 强制加入签名计算
16
+ 4、getObject支持设置DataType
17
+ 5、重新整理万象demo
18
+
19
+ fix
20
+ 1、修复 uploadFile 未对参数 Key 进行校验
21
+
22
+ ### Merged
23
+
24
+ - Dev/1.5.0 [`#98`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/98)
25
+ - Dev/sign pic operations [`#97`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/97)
26
+ - Feat/ci demo [`#94`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/94)
27
+
28
+ ### Commits
11
29
 
12
- feat
30
+ - Updated CHANGELOG.md [`2455c00`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/2455c00c3fe8eb44654a2e9c7876f04c51e3ca06)
13
31
 
14
- - 增加代码格式化
15
- - 提供base64方法
32
+ ## [v1.4.12](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.11...v1.4.12) - 2023-08-03
33
+
34
+ feat
35
+ - 增加代码格式化
36
+ - 提供base64方法
16
37
 
17
38
  ### Merged
18
39
 
@@ -24,9 +45,8 @@ feat
24
45
 
25
46
  ## [v1.4.11](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.10...v1.4.11) - 2023-07-26
26
47
 
27
- fix
28
-
29
- - 修复使用await异常bug
48
+ fix
49
+ - 修复使用await异常bug
30
50
 
31
51
  ### Merged
32
52
 
@@ -41,9 +61,8 @@ fix
41
61
 
42
62
  ## [v1.4.10](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.9...v1.4.10) - 2023-01-04
43
63
 
44
- feat
45
-
46
- - postObject支持x-cos-forbid-overwrite头部
64
+ feat
65
+ - postObject支持x-cos-forbid-overwrite头部
47
66
 
48
67
  ### Merged
49
68
 
@@ -55,9 +74,8 @@ feat
55
74
 
56
75
  ## [v1.4.9](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.8...v1.4.9) - 2022-12-29
57
76
 
58
- fix
59
-
60
- - 更新可以签入签名的headers
77
+ fix
78
+ - 更新可以签入签名的headers
61
79
 
62
80
  ### Merged
63
81
 
@@ -72,9 +90,8 @@ fix
72
90
 
73
91
  ## [v1.4.8](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.7...v1.4.8) - 2022-11-21
74
92
 
75
- feat
76
-
77
- - getObjectAcl支持传VersionId
93
+ feat
94
+ - getObjectAcl支持传VersionId
78
95
 
79
96
  ### Merged
80
97
 
@@ -86,9 +103,8 @@ feat
86
103
 
87
104
  ## [v1.4.7](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.6...v1.4.7) - 2022-11-09
88
105
 
89
- fix
90
-
91
- - 升级依赖包@xmldom/xmldom版本
106
+ fix
107
+ - 升级依赖包@xmldom/xmldom版本
92
108
 
93
109
  ### Merged
94
110
 
@@ -100,9 +116,8 @@ fix
100
116
 
101
117
  ## [v1.4.6](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.5...v1.4.6) - 2022-10-25
102
118
 
103
- fix
104
-
105
- - 修复批量上传uploadFiles偶现问题
119
+ fix
120
+ - 修复批量上传uploadFiles偶现问题
106
121
 
107
122
  ### Merged
108
123
 
@@ -114,9 +129,8 @@ fix
114
129
 
115
130
  ## [v1.4.5](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.4...v1.4.5) - 2022-10-22
116
131
 
117
- fix
118
-
119
- - getObjectUrl暂时只支持回调写法
132
+ fix
133
+ - getObjectUrl暂时只支持回调写法
120
134
 
121
135
  ### Merged
122
136
 
@@ -128,8 +142,8 @@ fix
128
142
 
129
143
  ## [v1.4.4](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.3...v1.4.4) - 2022-10-20
130
144
 
131
- - 分块复制支持续传
132
- - 合法域名校验支持内网域名和.cn域名
145
+ - 分块复制支持续传
146
+ - 合法域名校验支持内网域名和.cn域名
133
147
 
134
148
  ### Merged
135
149
 
@@ -141,9 +155,8 @@ fix
141
155
 
142
156
  ## [v1.4.3](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.2...v1.4.3) - 2022-09-22
143
157
 
144
- feat
145
-
146
- - 支持sdk内部获取上传文件大小,不再依赖用户传入的FileSize
158
+ feat
159
+ - 支持sdk内部获取上传文件大小,不再依赖用户传入的FileSize
147
160
 
148
161
  ### Merged
149
162
 
@@ -155,9 +168,8 @@ feat
155
168
 
156
169
  ## [v1.4.2](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.1...v1.4.2) - 2022-09-09
157
170
 
158
- fix
159
-
160
- - 修复已知问题
171
+ fix
172
+ - 修复已知问题
161
173
 
162
174
  ### Merged
163
175
 
@@ -170,9 +182,8 @@ fix
170
182
 
171
183
  ## [v1.4.1](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.4.0...v1.4.1) - 2022-09-01
172
184
 
173
- fix
174
-
175
- - 修复已知问题
185
+ fix
186
+ - 修复已知问题
176
187
 
177
188
  ### Commits
178
189
 
@@ -180,9 +191,8 @@ fix
180
191
 
181
192
  ## [v1.4.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.3.0...v1.4.0) - 2022-08-17
182
193
 
183
- feat
184
-
185
- - 新增beacon上报
194
+ feat
195
+ - 新增beacon上报
186
196
 
187
197
  ### Merged
188
198
 
@@ -194,11 +204,10 @@ feat
194
204
 
195
205
  ## [v1.3.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.2.1...v1.3.0) - 2022-08-09
196
206
 
197
- feat
198
-
199
- - webpack升级到4.x
200
- - putObject支持FilePath参数。同时传参FilePath和Body时,优先级Body>FilePath
201
- - 初始化支持指定SimpleUploadMethod,当调用高级上传uploadFile或批量上传uploadFiles时,对小文件执行简单上传方法postObject或putObject
207
+ feat
208
+ - webpack升级到4.x
209
+ - putObject支持FilePath参数。同时传参FilePath和Body时,优先级Body>FilePath
210
+ - 初始化支持指定SimpleUploadMethod,当调用高级上传uploadFile或批量上传uploadFiles时,对小文件执行简单上传方法postObject或putObject
202
211
 
203
212
  ### Merged
204
213
 
@@ -210,8 +219,7 @@ feat
210
219
 
211
220
  ## [v1.2.1](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.2.0...v1.2.1) - 2022-07-21
212
221
 
213
- feat
214
-
222
+ feat
215
223
  - 初始化支持HttpDNSServiceId参数,填写后代表开启 HttpDNS 服务。HttpDNS 用法详见https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html
216
224
 
217
225
  ### Merged
@@ -227,9 +235,8 @@ feat
227
235
 
228
236
  ## [v1.2.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.8...v1.2.0) - 2022-06-30
229
237
 
230
- fix
231
-
232
- - 修复使用postObject不能正确的pauseTask,cancelTask问题
238
+ fix
239
+ - 修复使用postObject不能正确的pauseTask,cancelTask问题
233
240
  - 签名回调里使用SecurityToken代替并兼容XCosSecurityToken
234
241
 
235
242
  ### Merged
@@ -248,9 +255,8 @@ fix
248
255
 
249
256
  ## [v1.1.8](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.7...v1.1.8) - 2022-06-23
250
257
 
251
- feat
252
-
253
- - putBucketCors支持ResponseVary
258
+ feat
259
+ - putBucketCors支持ResponseVary
254
260
  - 提高签名时Expires参数的优先级
255
261
 
256
262
  ### Merged
@@ -309,7 +315,7 @@ fix:修复host签名时不兼容全球加速域名
309
315
 
310
316
  ## [v1.1.3](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.2...v1.1.3) - 2021-12-03
311
317
 
312
- feat
318
+ feat
313
319
  -sdk入口文件默认为压缩版
314
320
 
315
321
  ### Commits
@@ -320,9 +326,9 @@ feat
320
326
 
321
327
  ## [v1.1.2](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.1...v1.1.2) - 2021-12-01
322
328
 
323
- - host参与签名
324
- - getObjectUrl签名签入Query
325
- - 新增参与签名的headers白名单
329
+ - host参与签名
330
+ - getObjectUrl签名签入Query
331
+ - 新增参与签名的headers白名单
326
332
  - 支持打包出.min.js
327
333
 
328
334
  ### Merged
@@ -345,8 +351,8 @@ fix:CIHost兼容处理
345
351
 
346
352
  ## [v1.1.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.0.13...v1.1.0) - 2021-11-17
347
353
 
348
- - 新增appendObject接口
349
- - 新增媒体处理demo
354
+ - 新增appendObject接口
355
+ - 新增媒体处理demo
350
356
  - 修复已知d.ts错误
351
357
 
352
358
  ### Merged
@@ -379,7 +385,7 @@ fix:修复uploadSliceItem
379
385
 
380
386
  ## [v1.0.12](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.0.11...v1.0.12) - 2021-11-11
381
387
 
382
- fix:修复getBucketReferer已知错误
388
+ fix:修复getBucketReferer已知错误
383
389
  feat:分块上传支持支持mimeLimit、trafficLimit
384
390
 
385
391
  ### Merged
@@ -415,8 +421,6 @@ fix:getObjectUrl报错问题
415
421
 
416
422
  ## [v1.0.9](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.0.8...v1.0.9) - 2021-06-11
417
423
 
418
- - 新增高级上传接口
419
-
420
424
  ### Merged
421
425
 
422
426
  - feat:新增高级上传uploadFile接口 [`#48`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/48)
@@ -0,0 +1,255 @@
1
+ const COS = require('../lib/cos-wx-sdk-v5');
2
+ const config = require('../config');
3
+ const { cos, requestCallback } = require('../tools');
4
+
5
+ const asrDao = {
6
+ '提交音频降噪任务 postNoiseReduction': postNoiseReduction,
7
+ '提交人声分离任务 postVoiceSeparate': postVoiceSeparate,
8
+ '提交语音合成任务 postTts': postTts,
9
+ '提交语音识别任务 postSpeechRecognition': postSpeechRecognition,
10
+ '查询语音识别队列 getAsrQueue': getAsrQueue,
11
+ '更新语音识别队列 putAsrQueue': putAsrQueue,
12
+ '查询语音识别开通状态 getAsrBucket': getAsrBucket,
13
+ };
14
+
15
+ function postNoiseReduction() {
16
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com/jobs';
17
+ var url = 'https://' + host;
18
+ var body = COS.util.json2xml({
19
+ Request: {
20
+ Tag: 'NoiseReduction',
21
+ Input: {
22
+ Object: 'ci/music.mp3', // 文件名,取值为文件在当前存储桶中的完整名称
23
+ },
24
+ Operation: {
25
+ Output: {
26
+ Bucket: config.Bucket, // 输出的存储桶
27
+ Region: config.Region, // 输出的存储桶的地域
28
+ Object: 'ci/out.mp3', // 输出的文件Key
29
+ },
30
+ },
31
+ // QueueId: '', // 任务所在的队列 ID,非必须
32
+ // CallBackFormat: '', // 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式,非必须
33
+ // CallBackType: '', // 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型,非必须
34
+ // CallBack: '', // 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调,非必须
35
+ // CallBackMqConfig: '', // 任务回调 TDMQ 配置,当 CallBackType 为 TDMQ 时必填,非必须
36
+ },
37
+ });
38
+ cos.request(
39
+ {
40
+ Method: 'POST',
41
+ Key: 'jobs',
42
+ Url: url,
43
+ Body: body,
44
+ ContentType: 'application/xml',
45
+ },
46
+ function (err, data) {
47
+ console.log(err || data);
48
+ }
49
+ );
50
+ }
51
+
52
+ function postVoiceSeparate() {
53
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com/jobs';
54
+ var url = 'https://' + host;
55
+ var body = COS.util.json2xml({
56
+ Request: {
57
+ Tag: 'VoiceSeparate',
58
+ Input: {
59
+ Object: 'ci/music.mp3', // 文件名,取值为文件在当前存储桶中的完整名称
60
+ },
61
+ Operation: {
62
+ // VoiceSeparate: {}, // 指定转码模板参数,非必须
63
+ TemplateId: 't13fca82ad97e84878a22cd81bd2e5652c', // 指定的模板 ID,必须
64
+ // JobLevel: 0, // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0,非必须
65
+ Output: {
66
+ Bucket: config.Bucket, // 输出的存储桶
67
+ Region: config.Region, // 输出的存储桶的地域
68
+ Object: 'ci/out/background.mp3', // 输出的文件Key,背景音结果文件名,不能与 AuObject 同时为空
69
+ AuObject: 'ci/out/audio.mp3',
70
+ },
71
+ },
72
+ // QueueId: '', // 任务所在的队列 ID,非必须
73
+ // CallBackFormat: '', // 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式,非必须
74
+ // CallBackType: '', // 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型,非必须
75
+ // CallBack: '', // 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调,非必须
76
+ // CallBackMqConfig: '', // 任务回调 TDMQ 配置,当 CallBackType 为 TDMQ 时必填,非必须
77
+ },
78
+ });
79
+ cos.request(
80
+ {
81
+ Method: 'POST',
82
+ Key: 'jobs',
83
+ Url: url,
84
+ Body: body,
85
+ ContentType: 'application/xml',
86
+ },
87
+ function (err, data) {
88
+ console.log(err || data);
89
+ }
90
+ );
91
+ }
92
+
93
+ function postTts() {
94
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com/jobs';
95
+ var url = 'https://' + host;
96
+ var body = COS.util.json2xml({
97
+ Request: {
98
+ Tag: 'Tts',
99
+ Operation: {
100
+ // VoiceSeparate: {}, // 指定转码模板参数,非必须
101
+ TemplateId: 't192931b3564084168a3f50ebfea59acb3', // 指定的模板 ID,必须
102
+ // JobLevel: 0, // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0,非必须
103
+ TtsConfig: {
104
+ InputType: 'Text',
105
+ Input: '床前明月光,疑是地上霜',
106
+ },
107
+ Output: {
108
+ Bucket: config.Bucket, // 输出的存储桶
109
+ Region: config.Region, // 输出的存储桶的地域
110
+ Object: 'ci/out/tts.mp3', // 输出的文件Key
111
+ },
112
+ },
113
+ // QueueId: '', // 任务所在的队列 ID,非必须
114
+ // CallBackFormat: '', // 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式,非必须
115
+ // CallBackType: '', // 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型,非必须
116
+ // CallBack: '', // 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调,非必须
117
+ // CallBackMqConfig: '', // 任务回调 TDMQ 配置,当 CallBackType 为 TDMQ 时必填,非必须
118
+ },
119
+ });
120
+ cos.request(
121
+ {
122
+ Method: 'POST',
123
+ Key: 'jobs',
124
+ Url: url,
125
+ Body: body,
126
+ ContentType: 'application/xml',
127
+ },
128
+ function (err, data) {
129
+ console.log(err || data);
130
+ }
131
+ );
132
+ }
133
+
134
+ function postSpeechRecognition() {
135
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com/asr_jobs';
136
+ var url = 'https://' + host;
137
+ var body = COS.util.json2xml({
138
+ Request: {
139
+ Tag: 'SpeechRecognition',
140
+ Input: {
141
+ Object: 'ci/music.mp3', // 文件名,取值为文件在当前存储桶中的完整名称,与Url参数二选一
142
+ // Url: 'http://examplebucket-1250000000.cos.ap-shanghai.myqcloud.com/music.mp3', // 病毒文件的链接地址,与Object参数二选一
143
+ },
144
+ Operation: {
145
+ SpeechRecognition: {
146
+ EngineModelType: '16k_zh_video', // 引擎模型类型
147
+ ChannelNum: 1, // 语音声道数
148
+ ResTextFormat: 0, // 识别结果返回形式
149
+ FilterDirty: 1, // 是否过滤脏词(目前支持中文普通话引擎)
150
+ FilterModal: 1, // 是否过语气词(目前支持中文普通话引擎)
151
+ ConvertNumMode: 0, // 是否进行阿拉伯数字智能转换(目前支持中文普通话引擎)
152
+ },
153
+ Output: {
154
+ Bucket: config.Bucket, // 输出的存储桶
155
+ Region: config.Region, // 输出的存储桶的地域
156
+ Object: 'ci/out/SpeechRecognition.mp3', // 输出的文件Key
157
+ },
158
+ },
159
+ // QueueId: '', // 任务所在的队列 ID,非必须
160
+ // CallBackFormat: '', // 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式,非必须
161
+ // CallBackType: '', // 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型,非必须
162
+ // CallBack: '', // 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调,非必须
163
+ // CallBackMqConfig: '', // 任务回调 TDMQ 配置,当 CallBackType 为 TDMQ 时必填,非必须
164
+ },
165
+ });
166
+ cos.request(
167
+ {
168
+ Method: 'POST',
169
+ Key: 'asr_jobs',
170
+ Url: url,
171
+ Body: body,
172
+ ContentType: 'application/xml',
173
+ },
174
+ function (err, data) {
175
+ console.log(err || data);
176
+ }
177
+ );
178
+ }
179
+
180
+ function getAsrQueue() {
181
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com/asrqueue';
182
+ var url = 'https://' + host;
183
+ cos.request(
184
+ {
185
+ Method: 'GET',
186
+ Key: 'asrqueue',
187
+ Url: url,
188
+ Query: {
189
+ // queueIds: '', /* 非必须,队列 ID,以“,”符号分割字符串 */
190
+ // state: '', /* 非必须,1=Active,2=Paused */
191
+ // pageNumber: 1, /* 非必须,第几页 */
192
+ // pageSize: 2, /* 非必须,每页个数 */
193
+ },
194
+ },
195
+ function (err, data) {
196
+ console.log(err || data);
197
+ }
198
+ );
199
+ }
200
+
201
+ function putAsrQueue() {
202
+ // 任务所在的队列 ID,请使用查询队列(https://cloud.tencent.com/document/product/460/46946)获取或前往万象控制台(https://cloud.tencent.com/document/product/460/46487)在存储桶中查询
203
+ var queueId = 'pcc77499e85c311edb9865254008618d9';
204
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com/asrqueue/' + queueId;
205
+ var url = 'https://' + host;
206
+ var body = COS.util.json2xml({
207
+ Request: {
208
+ Name: 'queue-doc-process-1',
209
+ QueueID: queueId,
210
+ State: 'Paused',
211
+ NotifyConfig: {
212
+ // Url: '',
213
+ // Type: 'Url',
214
+ // Event: '',
215
+ State: 'Off',
216
+ },
217
+ },
218
+ });
219
+ cos.request(
220
+ {
221
+ Method: 'PUT',
222
+ Key: 'asrqueue/' + queueId,
223
+ Url: url,
224
+ Body: body,
225
+ ContentType: 'application/xml',
226
+ },
227
+ function (err, data) {
228
+ console.log(err || data);
229
+ }
230
+ );
231
+ }
232
+
233
+ function getAsrBucket() {
234
+ var host = 'ci.' + config.Region + '.myqcloud.com/asrbucket';
235
+ var url = 'https://' + host;
236
+ cos.request(
237
+ {
238
+ Method: 'GET',
239
+ Key: 'asrbucket',
240
+ Url: url,
241
+ Query: {
242
+ // regions: '', /* 非必须,地域信息,以“,”分隔字符串,支持 All、ap-shanghai、ap-beijing */
243
+ // bucketNames: '', /* 非必须,存储桶名称,以“,”分隔,支持多个存储桶,精确搜索 */
244
+ // bucketName: '', /* 非必须,存储桶名称前缀,前缀搜索 */
245
+ // pageNumber: 1, /* 非必须,第几页 */
246
+ // pageSize: 10, /* 非必须,每页个数 */
247
+ },
248
+ },
249
+ function (err, data) {
250
+ console.log(err || data);
251
+ }
252
+ );
253
+ }
254
+
255
+ module.exports = asrDao;