diff --git a/demo/demo.js b/demo/demo.js index d6d23e0..1f761cb 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -4369,7 +4369,6 @@ function getFileCompressTask() { // 从 Bucket 里拆出 AppId const AppId = config.Bucket.substr(config.Bucket.lastIndexOf('-') + 1); -createDataset(); // 创建数据集 function createDataset() { const key = 'dataset'; // 固定值 diff --git a/package.json b/package.json index a06e9bd..cd511de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cos-nodejs-sdk-v5", - "version": "2.14.2", + "version": "2.14.3", "description": "cos nodejs sdk v5", "main": "index.js", "types": "index.d.ts", diff --git a/sdk/advance.js b/sdk/advance.js index a0d7907..e882fb4 100644 --- a/sdk/advance.js +++ b/sdk/advance.js @@ -1597,9 +1597,6 @@ function downloadFile(params, callback) { Output: writeStream, }, function (err, data) { - if (err && writeStream.writableFinished === false) { - writeStream.close && writeStream.close(); - } if (aborted) return; // 处理错误和进度 diff --git a/sdk/base.js b/sdk/base.js index ff9bb53..f32fbe2 100644 --- a/sdk/base.js +++ b/sdk/base.js @@ -4215,6 +4215,9 @@ function _submitRequest(params, callback) { }; sender.on('error', function (err) { + if (params.outputStream) { + params.outputStream.close && params.outputStream.close(); + } markLastBytesWritten(); cb(util.error(err)); }); diff --git a/sdk/util.js b/sdk/util.js index ebe4558..566dae2 100644 --- a/sdk/util.js +++ b/sdk/util.js @@ -529,14 +529,8 @@ var apiWrapper = function (apiName, apiFn) { delete params.AppId; } } - // 除了下列 api,如果 Key 是 / 开头,强制去掉第一个 / - var dontRemoveApi = ['sliceUploadFile', 'uploadFile', 'downloadFile', 'sliceCopyFile']; - if ( - !self.options.UseRawKey && - params.Key && - params.Key.substr(0, 1) === '/' && - !dontRemoveApi.includes(apiName) - ) { + // 如果 Key 是 / 开头,强制去掉第一个 / + if (!self.options.UseRawKey && params.Key && params.Key.substr(0, 1) === '/') { params.Key = params.Key.substr(1); } }