servlet:
multipart:
enabled: true
max-file-size: 100MB
max-request-size: 1GB
resolve-lazily: true
application.yml
resolve-lazily 추가 - 기본적으로 파일 사이즈 체크는 Spring MVC 진입 전 체크를 하기 때문에
ExceptionHandler 를 타지 않음
설정을 활성화하고 실제 파일 접근시에 체크 하게 함
#Exception Handler
@ExceptionHandler({
MaxUploadSizeExceededException.class
})
public @ResponseBody
ErrorResponse handleMaxUploadSizeException(MaxUploadSizeExceededException e) {
return new ErrorResponse(FileErrorCode.FE003.getCode(), FileErrorCode.FE003.getMessage());
}
MaxUploadSizeExceededException 핸들러 정의
'Spring' 카테고리의 다른 글
| [Spring Cloud] Spring Cloud Config Server - 3 (0) | 2024.07.18 |
|---|---|
| [Spring Cloud] Spring Cloud Config Server - 2 (0) | 2024.07.18 |
| [Spring Cloud] Spring Cloud Config Server - 1 (0) | 2024.07.18 |
| HttpServletRequest 객체 가져오기 (0) | 2024.07.11 |
| jjwt 0.9.x 이후 설정 (0) | 2024.07.11 |