update license structures and setup file storage services
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { BadRequestException } from '@nestjs/common'
|
||||
|
||||
export const imageFileFilter = (
|
||||
req: any,
|
||||
file: Express.Multer.File,
|
||||
callback: (error: Error | null, acceptFile: boolean) => void,
|
||||
) => {
|
||||
if (!file.mimetype.startsWith('image/')) {
|
||||
return callback(new BadRequestException('Only image files are allowed'), false)
|
||||
}
|
||||
|
||||
const allowed = ['image/jpeg', 'image/png', 'image/webp']
|
||||
|
||||
if (!allowed.includes(file.mimetype)) {
|
||||
return callback(
|
||||
new BadRequestException('Only JPEG, PNG, WEBP images are allowed'),
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
callback(null, true)
|
||||
}
|
||||
|
||||
export const multerImageOptions = {
|
||||
fileFilter: imageFileFilter,
|
||||
limits: { fileSize: 5 * 1024 * 1024 }, // 5MB
|
||||
}
|
||||
Reference in New Issue
Block a user