setup routine
This commit is contained in:
parent
70edd165ee
commit
2e3d0a755c
8 changed files with 147 additions and 13 deletions
27
src/middleware/multer.ts
Normal file
27
src/middleware/multer.ts
Normal 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 },
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue