Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/substr key #212

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4369,7 +4369,6 @@ function getFileCompressTask() {
// 从 Bucket 里拆出 AppId
const AppId = config.Bucket.substr(config.Bucket.lastIndexOf('-') + 1);

createDataset();
// 创建数据集
function createDataset() {
const key = 'dataset'; // 固定值
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 0 additions & 3 deletions sdk/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// 处理错误和进度
Expand Down
3 changes: 3 additions & 0 deletions sdk/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand Down
10 changes: 2 additions & 8 deletions sdk/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down