fix: 修复OSS删除单个文件失败的bug
## 问题 删除单个文件时使用DeleteObjectsCommand导致阿里云OSS报错: "Missing Some Required Arguments." ## 修复 - 改用DeleteObjectCommand删除单个文件 - 修复storage.js:1224的delete方法 - 与之前修复的rename方法保持一致 ## 影响 - ✅ 文件删除功能现在正常工作 - ✅ 与重命名功能使用相同的删除命令 - ✅ 完全兼容阿里云OSS **Bug数量:** 1个 **修改文件:** 1个
This commit is contained in:
@@ -1216,17 +1216,15 @@ class OssStorageClient {
|
|||||||
|
|
||||||
return { size: totalDeletedSize };
|
return { size: totalDeletedSize };
|
||||||
} else {
|
} else {
|
||||||
// 删除单个文件
|
// 删除单个文件(使用DeleteObjectCommand)
|
||||||
// 获取文件大小
|
// 获取文件大小
|
||||||
const size = statResult.size || 0;
|
const size = statResult.size || 0;
|
||||||
totalDeletedSize = size;
|
totalDeletedSize = size;
|
||||||
|
|
||||||
const command = new DeleteObjectsCommand({
|
const { DeleteObjectCommand } = require('@aws-sdk/client-s3');
|
||||||
|
const command = new DeleteObjectCommand({
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Delete: {
|
Key: key
|
||||||
Objects: [{ Key: key }],
|
|
||||||
Quiet: false
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.s3Client.send(command);
|
await this.s3Client.send(command);
|
||||||
|
|||||||
Reference in New Issue
Block a user