image upload and keep if not changed

This commit is contained in:
Julian Krauser 2025-04-30 10:43:31 +02:00
parent be52a51055
commit 5b3a72820a
3 changed files with 17 additions and 9 deletions

View file

@ -1,6 +1,7 @@
import multer from "multer";
import { FileSystemHelper } from "../helpers/fileSystemHelper";
import path from "path";
import BadRequestException from "../exceptions/badRequestException";
export const clubImageStorage = multer.diskStorage({
destination: FileSystemHelper.formatPath("/app"),
@ -19,6 +20,13 @@ export const clubImageStorage = multer.diskStorage({
export const clubImageMulter = multer({
storage: clubImageStorage,
fileFilter(req, file, cb) {
if (file.mimetype.startsWith("image/png")) {
cb(null, true);
} else {
cb(new BadRequestException("Wrong file format"));
}
},
});
export const clubImageUpload = clubImageMulter.fields([