-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5011ff
commit d7d112e
Showing
9 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/domain/activity/common/exceptions/image-invalid-mime.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { HttpStatus } from '@nestjs/common'; | ||
|
||
import { ApiException } from '@wink/swagger'; | ||
|
||
export class ImageInvalidMimeException extends ApiException { | ||
constructor() { | ||
super({ | ||
swagger: '사진 파일이 아닌 경우', | ||
message: '사진 파일이 아닙니다.', | ||
code: HttpStatus.BAD_REQUEST, | ||
}); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/domain/activity/common/exceptions/image-too-large.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { HttpStatus } from '@nestjs/common'; | ||
|
||
import { ApiException } from '@wink/swagger'; | ||
|
||
export class ImageTooLargeException extends ApiException { | ||
constructor() { | ||
super({ | ||
swagger: '사진의 용량이 너무 큰 경우', | ||
message: '사진의 용량은 10MB를 넘을 수 없습니다.', | ||
code: HttpStatus.BAD_REQUEST, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './image-invalid-mime.exception'; | ||
export * from './image-too-large.exception'; |
24 changes: 24 additions & 0 deletions
24
src/domain/activity/common/util/multer/image-filter.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { | ||
ImageInvalidMimeException, | ||
ImageTooLargeException, | ||
} from '@wink/activity/common/exceptions'; | ||
|
||
const IMAGE_MAX_SIZE = 1024 * 1024 * 10; | ||
|
||
export const ImageFilter = ( | ||
_req: Request, | ||
file: Express.Multer.File, | ||
callback: (error: Error | null, success: boolean) => void, | ||
) => { | ||
if (!file.mimetype.startsWith('image/')) { | ||
return callback(new ImageInvalidMimeException(), false); | ||
} | ||
|
||
if (file.size > IMAGE_MAX_SIZE) { | ||
return callback(new ImageTooLargeException(), false); | ||
} | ||
|
||
callback(null, true); | ||
}; | ||
|
||
export const ImageFilterException = [ImageInvalidMimeException, ImageTooLargeException]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './image-filter.util'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/domain/member/dto/request/update-my-avatar.request.dto.ts
This file was deleted.
Oops, something went wrong.