스프링

Spring Boot 파일 업로드 용량 제한 설정

코딍코딍 2023. 2. 23. 13:32

에러 메세지

스프링을 통해 파일 업로드를 구현하던중 위와 같은 오류메세지가 발생했다.

 

"The field imgFile exceeds its maximum permitted size of 1048576 bytes."

업로드 할 수 있는 파일의 최대 용량를 초과하여서 발생한 오류였다.

이 때, 1048576 bytes는 약 1MB로 용량 설정을 하지 않았을 때의 디폴트 값이다.

 

 

해결

해결 방법은 spring boot의 파일 용량 설정값을 변경하면 된다.

 

application.yml

spring:
  servlet: #파일 용량 설정
    multipart:
      max-file-size: 10MB
      max-request-size: 10MB