brocoders / nestjs-boilerplate

NestJS boilerplate. Auth, TypeORM, Mongoose, Postgres, MongoDB, Mailing, I18N, Docker.

Home Page:https://nestjs-boilerplate-test.herokuapp.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add new validation for files

Shchepotin opened this issue · comments

Replace this

fileFilter: (request, file, callback) => {
if (!file.originalname.match(/\.(jpg|jpeg|png|gif)$/i)) {
return callback(
new HttpException(
{
status: HttpStatus.UNPROCESSABLE_ENTITY,
errors: {
file: `cantUploadFileType`,
},
},
HttpStatus.UNPROCESSABLE_ENTITY,
),
false,
);
}

With

MaxFileSizeValidator and FileTypeValidator