fix: 确保保存图片时存储目录存在

This commit is contained in:
sliverp
2026-01-30 14:40:41 +08:00
parent 549956adda
commit cef1e7406c

View File

@@ -313,6 +313,11 @@ export function saveImage(
const ext = getExtFromMime(mimeType) || "png";
const filename = `${imageId}.${ext}`;
// 确保存储目录存在
if (!fs.existsSync(currentConfig.storageDir)) {
fs.mkdirSync(currentConfig.storageDir, { recursive: true });
}
// 保存文件
const filePath = path.join(currentConfig.storageDir, filename);
fs.writeFileSync(filePath, buffer);