diff --git a/backend/storage.js b/backend/storage.js index e1fc94a..8014a8b 100644 --- a/backend/storage.js +++ b/backend/storage.js @@ -321,6 +321,13 @@ class LocalStorageClient { // 更新内存中的值 this.user.local_storage_used = newUsed; } + + /** + * 格式化文件大小 + */ + formatSize(bytes) { + return formatFileSize(bytes); + } } // ===== OSS存储客户端 ===== @@ -538,7 +545,7 @@ class OssStorageClient { }); await this.s3Client.send(command); - console.log(`[OSS存储] 上传成功: ${key} (${this.formatSize(fileSize)})`); + console.log(`[OSS存储] 上传成功: ${key} (${formatFileSize(fileSize)})`); // 关闭流 if (!fileStream.destroyed) { @@ -744,7 +751,6 @@ class OssStorageClient { // OSS 中文件夹通过以斜杠结尾的空对象模拟 const folderKey = key.endsWith('/') ? key : `${key}/`; - const { PutObjectCommand } = require('@aws-sdk/client-s3'); const command = new PutObjectCommand({ Bucket: bucket, Key: folderKey, @@ -788,6 +794,13 @@ class OssStorageClient { return `${baseUrl}/${key}`; } + /** + * 格式化文件大小 + */ + formatSize(bytes) { + return formatFileSize(bytes); + } + /** * 关闭连接(S3Client 无需显式关闭) */