new features
This commit is contained in:
@@ -56,4 +56,39 @@ const multerOptions: any = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const uploadBestellung: any = multer(multerOptions);
|
||||
|
||||
export { UPLOAD_DIR, THUMBNAIL_DIR };
|
||||
// ── Wartungslog uploads (vehicle/equipment service reports) ──────────────────
|
||||
|
||||
const WARTUNG_DIR = path.join(APP_ROOT, 'uploads', 'wartung');
|
||||
try {
|
||||
if (!fs.existsSync(WARTUNG_DIR)) {
|
||||
fs.mkdirSync(WARTUNG_DIR, { recursive: true });
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn(`Could not create wartung upload directory`, { err });
|
||||
}
|
||||
|
||||
const wartungStorage = multer.diskStorage({
|
||||
destination(_req: any, _file: any, cb: any) {
|
||||
cb(null, WARTUNG_DIR);
|
||||
},
|
||||
filename(_req: any, file: any, cb: any) {
|
||||
const uniqueSuffix = `${Date.now()}-${Math.round(Math.random() * 1e9)}`;
|
||||
const ext = path.extname(file.originalname);
|
||||
cb(null, `${uniqueSuffix}${ext}`);
|
||||
},
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const uploadWartung: any = multer({
|
||||
storage: wartungStorage,
|
||||
fileFilter(_req: any, file: any, cb: any) {
|
||||
if (ALLOWED_TYPES.includes(file.mimetype)) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new Error(`Dateityp ${file.mimetype} ist nicht erlaubt.`));
|
||||
}
|
||||
},
|
||||
limits: { fileSize: 20 * 1024 * 1024 },
|
||||
});
|
||||
|
||||
export { UPLOAD_DIR, THUMBNAIL_DIR, WARTUNG_DIR };
|
||||
|
||||
Reference in New Issue
Block a user