Skip to content

Commit 68ba295

Browse files
authored
Fix/substr key (#212)
* fix: 默认截断 Key 中第一个斜杆 * fix: --other=优化下载异常处理 * fix: demo 优化
1 parent c68ee53 commit 68ba295

File tree

5 files changed

+6
-13
lines changed

5 files changed

+6
-13
lines changed

demo/demo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4369,7 +4369,6 @@ function getFileCompressTask() {
43694369
// 从 Bucket 里拆出 AppId
43704370
const AppId = config.Bucket.substr(config.Bucket.lastIndexOf('-') + 1);
43714371

4372-
createDataset();
43734372
// 创建数据集
43744373
function createDataset() {
43754374
const key = 'dataset'; // 固定值

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-nodejs-sdk-v5",
3-
"version": "2.14.2",
3+
"version": "2.14.3",
44
"description": "cos nodejs sdk v5",
55
"main": "index.js",
66
"types": "index.d.ts",

sdk/advance.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,9 +1597,6 @@ function downloadFile(params, callback) {
15971597
Output: writeStream,
15981598
},
15991599
function (err, data) {
1600-
if (err && writeStream.writableFinished === false) {
1601-
writeStream.close && writeStream.close();
1602-
}
16031600
if (aborted) return;
16041601

16051602
// 处理错误和进度

sdk/base.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,6 +4215,9 @@ function _submitRequest(params, callback) {
42154215
};
42164216

42174217
sender.on('error', function (err) {
4218+
if (params.outputStream) {
4219+
params.outputStream.close && params.outputStream.close();
4220+
}
42184221
markLastBytesWritten();
42194222
cb(util.error(err));
42204223
});

sdk/util.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,8 @@ var apiWrapper = function (apiName, apiFn) {
529529
delete params.AppId;
530530
}
531531
}
532-
// 除了下列 api,如果 Key 是 / 开头,强制去掉第一个 /
533-
var dontRemoveApi = ['sliceUploadFile', 'uploadFile', 'downloadFile', 'sliceCopyFile'];
534-
if (
535-
!self.options.UseRawKey &&
536-
params.Key &&
537-
params.Key.substr(0, 1) === '/' &&
538-
!dontRemoveApi.includes(apiName)
539-
) {
532+
// 如果 Key 是 / 开头,强制去掉第一个 /
533+
if (!self.options.UseRawKey && params.Key && params.Key.substr(0, 1) === '/') {
540534
params.Key = params.Key.substr(1);
541535
}
542536
}

0 commit comments

Comments
 (0)