setup routine

This commit is contained in:
Julian Krauser 2025-04-25 08:18:49 +02:00
parent 70edd165ee
commit 2e3d0a755c
8 changed files with 147 additions and 13 deletions

27
src/middleware/multer.ts Normal file
View file

@ -0,0 +1,27 @@
import multer from "multer";
import { FileSystemHelper } from "../helpers/fileSystemHelper";
import path from "path";
export const clubImageStorage = multer.diskStorage({
destination: FileSystemHelper.formatPath("/app"),
filename: function (req, file, cb) {
const fileExtension = path.extname(file.originalname).toLowerCase();
if (file.fieldname === "icon") {
cb(null, "company-icon" + fileExtension);
} else if (file.fieldname === "logo") {
cb(null, "company-logo" + fileExtension);
} else {
cb(null, file.originalname);
}
},
});
export const clubImageMulter = multer({
storage: clubImageStorage,
});
export const clubImageUpload = clubImageMulter.fields([
{ name: "icon", maxCount: 1 },
{ name: "logo", maxCount: 1 },
]);