cos-wx-sdk-v5 1.1.8 → 1.3.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/.babelrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["@babel/preset-env"]
3
+ }
package/CHANGELOG.md CHANGED
@@ -7,6 +7,66 @@ 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.2.1](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.2.0...v1.2.1) - 2022-07-21
11
+
12
+ feat
13
+ - 初始化支持HttpDNSServiceId参数,填写后代表开启 HttpDNS 服务。HttpDNS 用法详见https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html
14
+
15
+ ### Merged
16
+
17
+ - feat: 1.2.1 [`#70`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/70)
18
+ - Feat/1.2.0 [`#69`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/69)
19
+
20
+ ### Commits
21
+
22
+ - Merge https://github.com/livehigh/cos-wx-sdk-v5 into feat/1.2.1 [`982305a`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/982305a2f4ce6b5d6e55e8dc96f1b14eedcc9297)
23
+ - upd 去掉ForcePathStyle处理 [`6ed7dcc`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/6ed7dccc092cde1e43c54101870191fce7eaba49)
24
+ - upd 补充HttpDNS使用说明 [`c80f440`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/c80f440d2d75be962433250e824a331c7142979c)
25
+
26
+ ## [v1.2.0](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.8...v1.2.0) - 2022-06-30
27
+
28
+ fix
29
+ - 修复使用postObject不能正确的pauseTask,cancelTask问题
30
+ - 签名回调里使用SecurityToken代替并兼容XCosSecurityToken
31
+
32
+ ### Merged
33
+
34
+ - 完善内容审核demo [`#68`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/68)
35
+ - Feat/1.1.8 [`#67`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/67)
36
+
37
+ ### Commits
38
+
39
+ - feat 1.2.0 [`0fc7281`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/0fc7281a43a6d9f3bf1f125c04fabdf63bcc9f4c)
40
+ - upd demo [`8e198e3`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/8e198e3742c778844e82ebc8c6bca777d0ae58e6)
41
+ - upd [`8f6170f`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/8f6170f15972c479963c1b78816d4a8a13dd8fd8)
42
+ - del [`c12abe9`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/c12abe9e93dd07607d46f2e61286a16dfb17721e)
43
+ - upd [`2035c54`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/2035c54193d7c96030bc5b364c100b952f62d627)
44
+ - upd [`a8142cc`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/a8142cca3aa5e822b2509bf2c3a2a96402a343d8)
45
+
46
+ ## [v1.1.8](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.7...v1.1.8) - 2022-06-23
47
+
48
+ feat
49
+ - putBucketCors支持ResponseVary
50
+ - 提高签名时Expires参数的优先级
51
+
52
+ ### Merged
53
+
54
+ - feat:更换依赖xmldom->@xmldom/xmldom [`#66`](https://github.com/tencentyun/cos-wx-sdk-v5/pull/66)
55
+
56
+ ### Commits
57
+
58
+ - feat 1.1.8 [`aad1bad`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/aad1badffefc14d06a1d7f0851bc7aeec09bcd51)
59
+ - upd [`42134c3`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/42134c36def10a6a84d9b9c45dc56fe5e67e880a)
60
+
61
+ ## [v1.1.7](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.6...v1.1.7) - 2022-04-26
62
+
63
+ feat:更换依赖xmldom->@xmldom/xmldom
64
+
65
+ ### Commits
66
+
67
+ - feat:更换依赖xmldom->@xmldom/xmldom [`ca08986`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/ca08986fb0577e96fa2a924aa8ddd9e13bb5a82a)
68
+ - Updated CHANGELOG.md [`3c2359a`](https://github.com/tencentyun/cos-wx-sdk-v5/commit/3c2359a2f95df088fec2ae221f43be6c58b27537)
69
+
10
70
  ## [v1.1.6](https://github.com/tencentyun/cos-wx-sdk-v5/compare/v1.1.5...v1.1.6) - 2022-04-25
11
71
 
12
72
  feat:getObjectUrl支持全球加速参数
package/build.js CHANGED
@@ -2,6 +2,7 @@ var webpack = require('webpack');
2
2
  var path = require('path');
3
3
  var fs = require('fs');
4
4
  var pkg = require('./package.json');
5
+ const TerserPlugin = require('terser-webpack-plugin');
5
6
 
6
7
  var replaceVersion = function () {
7
8
  var filePath = path.resolve(__dirname, 'src/cos.js');
@@ -32,6 +33,8 @@ var replaceDevCode = function (list) {
32
33
  replaceVersion();
33
34
 
34
35
  var config = {
36
+ mode: process.env.NODE_ENV,
37
+ devtool: "none",
35
38
  watch: true,
36
39
  entry: path.resolve(__dirname, './index.js'),
37
40
  output: {
@@ -46,11 +49,20 @@ var config = {
46
49
  {
47
50
  test: /\.m?js$/,
48
51
  loader: 'babel-loader',
49
- options: {
50
- presets: ['es2015']
51
- }
52
+ exclude: /node_modules/,
52
53
  }
53
- ]
54
+ ],
55
+ },
56
+ optimization: {
57
+ minimize: false,
58
+ minimizer: [
59
+ new TerserPlugin({
60
+ cache: true,
61
+ parallel: true,
62
+ sourceMap: true,
63
+ extractComments: false,
64
+ }),
65
+ ],
54
66
  },
55
67
  devServer: {
56
68
  historyApiFallback: true,
@@ -70,24 +82,29 @@ if (process.env.NODE_ENV === 'production') {
70
82
  ]);
71
83
  config.watch = false;
72
84
  config.output.filename = 'cos-wx-sdk-v5.min.js';
85
+ config.optimization = {
86
+ minimize: true,
87
+ minimizer: [
88
+ new TerserPlugin({
89
+ cache: true,
90
+ parallel: true,
91
+ sourceMap: true,
92
+ extractComments: false,
93
+ terserOptions: {
94
+ compress: {
95
+ drop_debugger: true,
96
+ drop_console: true,
97
+ }
98
+ },
99
+ }),
100
+ ],
101
+ };
73
102
  config.plugins = (config.plugins || []).concat([
74
103
  new webpack.DefinePlugin({
75
104
  'process.env': {
76
105
  NODE_ENV: '"production"'
77
106
  }
78
107
  }),
79
- new webpack.optimize.UglifyJsPlugin({
80
- sourceMap: true,
81
- output: {
82
- ascii_only: true,
83
- },
84
- compress: {
85
- warnings: false,
86
- },
87
- }),
88
- new webpack.LoaderOptionsPlugin({
89
- minimize: true
90
- }),
91
108
  ]);
92
109
  }
93
110
 
@@ -95,10 +112,12 @@ webpack(config, function (err, stats) {
95
112
  // 每次运行 npm run build,将 sourcePath 代码复制一份放入 targetPath
96
113
  var sourcePath = path.resolve(__dirname, './demo/lib/cos-wx-sdk-v5.js');
97
114
  var targetPath = path.resolve(__dirname, './demo-album/lib/cos-wx-sdk-v5.js');
98
- var minSourcePath = path.resolve(__dirname, './demo/lib/cos-wx-sdk-v5.min.js');
99
- var mintTargetPath = path.resolve(__dirname, './demo-album/lib/cos-wx-sdk-v5.min.js');
100
115
  fs.createReadStream(sourcePath).pipe(fs.createWriteStream(targetPath));
101
- fs.createReadStream(minSourcePath).pipe(fs.createWriteStream(mintTargetPath));
116
+ if (process.env.NODE_ENV === 'production') {
117
+ var minSourcePath = path.resolve(__dirname, './demo/lib/cos-wx-sdk-v5.min.js');
118
+ var mintTargetPath = path.resolve(__dirname, './demo-album/lib/cos-wx-sdk-v5.min.js');
119
+ fs.createReadStream(minSourcePath).pipe(fs.createWriteStream(mintTargetPath));
120
+ }
102
121
  if (err) throw err
103
122
  process.stdout.write(stats.toString({
104
123
  colors: true,
package/demo/demo-sdk.js CHANGED
@@ -22,7 +22,7 @@ var getAuthorization = function(options, callback) {
22
22
  callback({
23
23
  TmpSecretId: credentials.tmpSecretId,
24
24
  TmpSecretKey: credentials.tmpSecretKey,
25
- XCosSecurityToken: credentials.sessionToken,
25
+ SecurityToken: credentials.sessionToken,
26
26
  StartTime: data.startTime, // 时间戳,单位秒,如:1580000000,建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
27
27
  ExpiredTime: data.expiredTime, // 时间戳,单位秒,如:1580000900
28
28
  });
@@ -159,7 +159,11 @@ var toolsDao = {
159
159
  Region: config.Region,
160
160
  Key: file.name,
161
161
  FilePath: file.path,
162
+ FileSize: file.size,
162
163
  SliceSize: 1024 * 1024 * 5, // 文件大于5mb自动使用分块上传
164
+ onTaskReady: function(taskId) {
165
+ TaskId = taskId
166
+ },
163
167
  onProgress: function (info) {
164
168
  var percent = parseInt(info.percent * 10000) / 100;
165
169
  var speed = parseInt(info.speed / 1024 / 1024 * 100) / 100;
@@ -681,7 +685,7 @@ var objectDao = {
681
685
  Position: 0,
682
686
  },
683
687
  function(err, data) {
684
- logger.log('putObject:', err || data);
688
+ console.log('putObject:', err || data);
685
689
  })
686
690
  },
687
691
  'appendObject_continue 继续追加上传': function() {
@@ -704,7 +708,7 @@ var objectDao = {
704
708
  function(err, data) {
705
709
  // 也可以取到下一次上传的position继续追加上传
706
710
  // var nextPosition = data.headers['x-cos-next-append-position'];
707
- logger.log('putObject:', err || data);
711
+ console.log('putObject:', err || data);
708
712
  })
709
713
  });
710
714
  },
@@ -947,6 +951,285 @@ var ciObjectDao = {
947
951
  console.log(err || data);
948
952
  });
949
953
  },
954
+ '图片同步审核 getImageAuditing': function () {
955
+ cos.request({
956
+ Bucket: config.Bucket,
957
+ Region: config.Region,
958
+ Method: 'GET',
959
+ Key: '1.png',
960
+ Query: {
961
+ 'ci-process': 'sensitive-content-recognition', /** 固定值,必须 */
962
+ 'biz-type': '', /** 审核类型,非必须 */
963
+ 'detect-type': 'porn,ads', /** 审核策略,不填写则使用默认策略,非必须 */
964
+ 'detect-url': '', /** 审核任意公网可访问的图片链接,非必须 */
965
+ 'interval': 5, /** 审核 GIF 动图时,每隔interval帧截取一帧,非必须 */
966
+ 'max-frames': 5, /** 审核 GIF 动图时,最大截帧数,非必须 */
967
+ 'large-image-detect': '0', /** 是否需要压缩图片后再审核,非必须 */
968
+ },
969
+ },
970
+ function(err, data){
971
+ console.log(err || data);
972
+ });
973
+ },
974
+ '图片批量审核 postImagesAuditing': function () {
975
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
976
+ var url = 'https://' + host + '/image/auditing';
977
+ var body = COS.util.json2xml({
978
+ Request: {
979
+ Input: [{
980
+ Object: '1.png',
981
+ }, {
982
+ Object: '6.png',
983
+ }],
984
+ Conf: {
985
+ BizType: '',
986
+ DetectType: 'Porn'
987
+ }
988
+ }
989
+ });
990
+ cos.request({
991
+ Bucket: config.Bucket,
992
+ Region: config.Region,
993
+ Method: 'POST',
994
+ Url: url,
995
+ Key: '/image/auditing',
996
+ ContentType: 'application/xml',
997
+ Body: body
998
+ },
999
+ function(err, data){
1000
+ console.log(err || data);
1001
+ });
1002
+ },
1003
+ '查询图片审核任务结果 getImageAuditingResult': function () {
1004
+ var jobId = 'si8263213daf3711eca0d1525400d88xxx'; // jobId可以通过图片批量审核返回
1005
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1006
+ var url = 'https://' + host + '/image/auditing/' + jobId;
1007
+ cos.request({
1008
+ Bucket: config.Bucket,
1009
+ Region: config.Region,
1010
+ Method: 'GET',
1011
+ Key: '/image/auditing/' + jobId,
1012
+ Url: url,
1013
+ },
1014
+ function(err, data){
1015
+ console.log(err || data);
1016
+ });
1017
+ },
1018
+ '提交视频审核任务 postVideoAuditing': function() {
1019
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1020
+ var url = 'https://' + host + '/video/auditing';
1021
+ var body = COS.util.json2xml({
1022
+ Request: {
1023
+ Input: {
1024
+ Object: '1.mp4',
1025
+ },
1026
+ Conf: {
1027
+ BizType: '',
1028
+ DetectType: 'Porn',
1029
+ Snapshot: {
1030
+ Count: 1000, // 视频截帧数量
1031
+ },
1032
+ DetectContent: 1, // 是否审核视频声音,0-只审核视频不审核声音;1-审核视频+声音
1033
+ }
1034
+ }
1035
+ });
1036
+ cos.request({
1037
+ Bucket: config.Bucket,
1038
+ Region: config.Region,
1039
+ Method: 'POST',
1040
+ Url: url,
1041
+ Key: '/video/auditing',
1042
+ ContentType: 'application/xml',
1043
+ Body: body
1044
+ },
1045
+ function(err, data){
1046
+ console.log(err || data);
1047
+ });
1048
+ },
1049
+ '查询视频审核任务结果 getVideoAuditingResult': function () {
1050
+ var jobId = 'av5bd873d9f39011ecb6c95254009a49da'; // jobId可以通过提交视频审核任务返回
1051
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1052
+ var url = 'https://' + host + '/video/auditing/' + jobId;
1053
+ cos.request({
1054
+ Bucket: config.Bucket,
1055
+ Region: config.Region,
1056
+ Method: 'GET',
1057
+ Key: '/video/auditing/' + jobId,
1058
+ Url: url,
1059
+ },
1060
+ function(err, data){
1061
+ console.log(err || data);
1062
+ });
1063
+ },
1064
+ '提交音频审核任务 postAudioAuditing': function () {
1065
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1066
+ var url = 'https://' + host + '/audio/auditing';
1067
+ var body = COS.util.json2xml({
1068
+ Request: {
1069
+ Input: {
1070
+ Object: '1.mp3',
1071
+ },
1072
+ Conf: {
1073
+ BizType: '',
1074
+ DetectType: 'Porn',
1075
+ }
1076
+ }
1077
+ });
1078
+ cos.request({
1079
+ Bucket: config.Bucket,
1080
+ Region: config.Region,
1081
+ Method: 'POST',
1082
+ Url: url,
1083
+ Key: '/audio/auditing',
1084
+ ContentType: 'application/xml',
1085
+ Body: body
1086
+ },
1087
+ function(err, data){
1088
+ console.log(err || data);
1089
+ });
1090
+ },
1091
+ '查询音频审核任务结果 getAudioAuditingResult': function () {
1092
+ var jobId = 'sa0c28d41daff411ecb23352540078cxxx'; // jobId可以通过提交音频审核任务返回
1093
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1094
+ var url = 'https://' + host + '/audio/auditing/' + jobId;
1095
+ cos.request({
1096
+ Bucket: config.Bucket,
1097
+ Region: config.Region,
1098
+ Method: 'GET',
1099
+ Key: '/audio/auditing/' + jobId,
1100
+ Url: url,
1101
+ },
1102
+ function(err, data){
1103
+ console.log(err || data);
1104
+ });
1105
+ },
1106
+ '提交文本审核任务 postTextAuditing': function () {
1107
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1108
+ var url = 'https://' + host + '/text/auditing';
1109
+ var body = COS.util.json2xml({
1110
+ Request: {
1111
+ Input: {
1112
+ // Object: 'hello.txt', // 存在cos里的资源,审核结果异步返回,可以调用查询文本审核结果api查询
1113
+ Content: '5Lmz5rKf', // 经过base64编码过的文本”乳沟“,查询结果同步返回
1114
+ },
1115
+ Conf: {
1116
+ BizType: '',
1117
+ DetectType: 'Porn',
1118
+ }
1119
+ }
1120
+ });
1121
+ cos.request({
1122
+ Bucket: config.Bucket,
1123
+ Region: config.Region,
1124
+ Method: 'POST',
1125
+ Url: url,
1126
+ Key: '/text/auditing',
1127
+ ContentType: 'application/xml',
1128
+ Body: body
1129
+ },
1130
+ function(err, data){
1131
+ console.log(err || data);
1132
+ });
1133
+ },
1134
+ '查询文本审核任务结果 getTextAuditingResult': function () {
1135
+ var jobId = 'st8d88c664aff511ecb23352540078cxxx'; // jobId可以通过提交文本审核任务返回(Input传入Object)
1136
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1137
+ var url = 'https://' + host + '/text/auditing/' + jobId;
1138
+ cos.request({
1139
+ Bucket: config.Bucket,
1140
+ Region: config.Region,
1141
+ Method: 'GET',
1142
+ Key: '/text/auditing/' + jobId,
1143
+ Url: url,
1144
+ },
1145
+ function(err, data){
1146
+ console.log(err || data);
1147
+ });
1148
+ },
1149
+ '提交文档审核任务 postDocumentAuditing': function () {
1150
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1151
+ var url = 'https://' + host + '/document/auditing';
1152
+ var body = COS.util.json2xml({
1153
+ Request: {
1154
+ Input: {
1155
+ Object: 'test.xlsx', // 存在cos里的资源,审核结果异步返回,可以调用查询文本审核结果api查询
1156
+ },
1157
+ Conf: {
1158
+ BizType: '',
1159
+ DetectType: 'Porn',
1160
+ }
1161
+ }
1162
+ });
1163
+ cos.request({
1164
+ Bucket: config.Bucket,
1165
+ Region: config.Region,
1166
+ Method: 'POST',
1167
+ Url: url,
1168
+ Key: '/document/auditing',
1169
+ ContentType: 'application/xml',
1170
+ Body: body
1171
+ },
1172
+ function(err, data){
1173
+ console.log(err || data);
1174
+ });
1175
+ },
1176
+ '查询文档审核任务结果 getDocumentAuditingResult': function () {
1177
+ var jobId = 'sd7815c21caff611eca12f525400d88560'; // jobId可以通过提交文档审核任务返回
1178
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1179
+ var url = 'https://' + host + '/document/auditing/' + jobId;
1180
+ cos.request({
1181
+ Bucket: config.Bucket,
1182
+ Region: config.Region,
1183
+ Method: 'GET',
1184
+ Key: '/document/auditing/' + jobId,
1185
+ Url: url,
1186
+ },
1187
+ function(err, data){
1188
+ console.log(err || data);
1189
+ });
1190
+ },
1191
+ '提交网页审核任务 postWebpageAuditing': function () {
1192
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1193
+ var url = 'https://' + host + '/webpage/auditing';
1194
+ var body = COS.util.json2xml({
1195
+ Request: {
1196
+ Input: {
1197
+ Url: 'https://cloud.tencent.com/', // 存在cos里的资源,审核结果异步返回,可以调用查询文本审核结果api查询
1198
+ },
1199
+ Conf: {
1200
+ BizType: '',
1201
+ DetectType: 'Porn,Ads',
1202
+ }
1203
+ }
1204
+ });
1205
+ cos.request({
1206
+ Bucket: config.Bucket,
1207
+ Region: config.Region,
1208
+ Method: 'POST',
1209
+ Url: url,
1210
+ Key: '/webpage/auditing',
1211
+ ContentType: 'application/xml',
1212
+ Body: body
1213
+ },
1214
+ function(err, data){
1215
+ console.log(err || data);
1216
+ });
1217
+ },
1218
+ '查询网页审核任务结果 getWebpageAuditingResult': function () {
1219
+ var jobId = 'shce868019aff611ecb1155254009a4xxx'; // jobId可以通过提交网页审核任务返回
1220
+ var host = config.Bucket + '.ci.' + config.Region + '.myqcloud.com';
1221
+ var url = 'https://' + host + '/webpage/auditing/' + jobId;
1222
+ cos.request({
1223
+ Bucket: config.Bucket,
1224
+ Region: config.Region,
1225
+ Method: 'GET',
1226
+ Key: '/webpage/auditing/' + jobId,
1227
+ Url: url,
1228
+ },
1229
+ function(err, data){
1230
+ console.log(err || data);
1231
+ });
1232
+ },
950
1233
  }
951
1234
 
952
1235
  // require('./test');