修复附件和背景保存异常

This commit is contained in:
eoao
2026-01-03 00:01:16 +08:00
parent a0553203ce
commit 877f03a8cf
+12 -17
View File
@@ -1,7 +1,6 @@
import s3Service from './s3-service';
import settingService from './setting-service';
import kvObjService from './kv-obj-service';
import { settingConst } from '../const/entity-const';
const r2Service = {
@@ -23,22 +22,20 @@ const r2Service = {
async putObj(c, key, content, metadata) {
const { kvStorage } = await settingService.query(c);
if (kvStorage === settingConst.kvStorage.OPEN) {
const storageType = await this.storageType(c);
if (storageType === 'KV') {
await kvObjService.putObj(c, key, content, metadata);
}
} else if (c.env.r2) {
if (storageType === 'R2') {
await c.env.r2.put(key, content, {
httpMetadata: { ...metadata }
});
}
} else {
if (storageType === 'S3') {
await s3Service.putObj(c, key, content, metadata);
}
},
@@ -49,20 +46,18 @@ const r2Service = {
async delete(c, key) {
const { kvStorage } = await settingService.query(c);
if (kvStorage === settingConst.kvStorage.OPEN) {
const storageType = await this.storageType(c);
if (storageType === 'KV') {
await kvObjService.deleteObj(c, key);
}
} else if (c.env.r2) {
if (storageType === 'R2') {
await c.env.r2.delete(key);
}
} else {
if (storageType === 'S3'){
await s3Service.deleteObj(c, key);
}
}