image upload and keep if not changed
This commit is contained in:
parent
be52a51055
commit
5b3a72820a
3 changed files with 17 additions and 9 deletions
|
@ -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([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue