fix: 确保保存图片时存储目录存在
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user