[Error/Spring] Maximum upload size exceeded
2023. 9. 13. 10:00ㆍBackend/Spring


에러:
Maximum upload size exceeded
원인:
upload size 가 기본적으로 약 1MB로 설정되어 있다. 그런데 2MB 가 넘는 이미지 파일을 업로드하려고 했기에, 위와 같은 에러가 발생하였다.
과정:
* 참고로 IntelliJ, myBatis, Gradle(Groovy) 이용중입니다.
1. 이미지 파일을 업로드하지 않거나, 파일 크기를 축소한다.
-> 개발자 입장에서는 상관 없지만, 사이트를 이용하는 사람 입장에서는 파일 용량에 대해 큰 고민을 하지 않을 수도 있다.
2. 따라서, 업로드를 할 수 있는 파일 크기를 키우기로 결정했다. 데이터는 @PostMapping 통해서 DB까지 연동하려고 한다.
해결
application.properties 파일에 다음과 같은 코드를 추가함으로 문제는 해결되었다.
| #이미지 크기 spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB server.tomcat.max-http-form-post-size=50MB |
여기서
1) spring.servlet.multipart.max-file-size: 업로드되는 파일의 최대 크기를 나타낸다
2) spring.servlet.multipart.max-requestsize : 전체 파일 업로드 요청의 최대 크기를 나타낸다
3) server.tomcat.max-http-form-post-size: Tomcat 서버에서 HTTP POST 요청으로 전송되는 데이터의 최대 크기를 나타낸다
'Backend > Spring' 카테고리의 다른 글
| [Spring] 객체 지향, 인터페이스, 스프링 (0) | 2024.01.08 |
|---|---|
| [Spring] hello world 띄워보기 + MySQL 및 JPA 연결 확인 (0) | 2023.09.15 |
| [Error/Spring] org.apache.ibatis.binding.bingdingException: parameter ' ' not found (0) | 2023.08.28 |
| [Spring] h2 console 에서 다른 값이 나와 초기화할 때 (1) | 2023.08.23 |
| [Spring] Spring Boot & IntelliJ 추가 설정, h2 (0) | 2023.08.22 |