@@ -9,7 +9,7 @@ import fsp from 'fs/promises'; // Use fs.promises for async file operations
|
|||||||
// --- 背景图片上传配置 (保持不变) ---
|
// --- 背景图片上传配置 (保持不变) ---
|
||||||
const backgroundStorage = multer.diskStorage({
|
const backgroundStorage = multer.diskStorage({
|
||||||
destination: (req, file, cb) => {
|
destination: (req, file, cb) => {
|
||||||
const uploadPath = path.join(__dirname, '../../uploads/backgrounds/');
|
const uploadPath = path.join(__dirname, '../../data/background/');
|
||||||
// 确保目录存在
|
// 确保目录存在
|
||||||
fs.mkdirSync(uploadPath, { recursive: true });
|
fs.mkdirSync(uploadPath, { recursive: true });
|
||||||
cb(null, uploadPath);
|
cb(null, uploadPath);
|
||||||
@@ -134,7 +134,7 @@ export const getBackgroundFileController = async (req: Request, res: Response):
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 构建文件的绝对路径 (基于 multer 的保存位置)
|
// 构建文件的绝对路径 (基于 multer 的保存位置)
|
||||||
const absolutePath = path.join(__dirname, '../../uploads/backgrounds/', filename);
|
const absolutePath = path.join(__dirname, '../../data/background/', filename);
|
||||||
|
|
||||||
// 检查文件是否存在且可读
|
// 检查文件是否存在且可读
|
||||||
await fsp.access(absolutePath, fs.constants.R_OK);
|
await fsp.access(absolutePath, fs.constants.R_OK);
|
||||||
|
|||||||
Reference in New Issue
Block a user