mirror of
https://github.com/immich-app/immich.git
synced 2024-11-16 10:28:54 -07:00
Added log for unsupported Mime type
This commit is contained in:
parent
d3bc92c3f8
commit
ab56ab9b27
@ -1,5 +1,5 @@
|
|||||||
import { APP_UPLOAD_LOCATION } from '@app/common/constants';
|
import { APP_UPLOAD_LOCATION } from '@app/common/constants';
|
||||||
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
|
import { BadRequestException, Logger, UnauthorizedException } from '@nestjs/common';
|
||||||
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
@ -9,6 +9,8 @@ import { extname, join } from 'path';
|
|||||||
import sanitize from 'sanitize-filename';
|
import sanitize from 'sanitize-filename';
|
||||||
import { patchFormData } from '../utils/path-form-data.util';
|
import { patchFormData } from '../utils/path-form-data.util';
|
||||||
|
|
||||||
|
const logger = new Logger('AssetUploadConfig');
|
||||||
|
|
||||||
export const assetUploadOption: MulterOptions = {
|
export const assetUploadOption: MulterOptions = {
|
||||||
fileFilter,
|
fileFilter,
|
||||||
storage: diskStorage({
|
storage: diskStorage({
|
||||||
@ -30,6 +32,7 @@ function fileFilter(req: Request, file: any, cb: any) {
|
|||||||
) {
|
) {
|
||||||
cb(null, true);
|
cb(null, true);
|
||||||
} else {
|
} else {
|
||||||
|
logger.error(`Unsupported file type ${extname(file.originalname)} file MIME type ${file.mimetype}`);
|
||||||
cb(new BadRequestException(`Unsupported file type ${extname(file.originalname)}`), false);
|
cb(new BadRequestException(`Unsupported file type ${extname(file.originalname)}`), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user