RestTemplate 대용량 파일 전송 시 OOM(Out Of Memory) 이 발생하여 검색 중 아래 방법처럼 설정 해준 후 오류를 해결 할 수 있었다.

 

[해결방법]

RestTemplate가 내부적으로 버퍼를 사용하게 되는데  requestFactory.setBufferRequestBody(false);를 사용하여 옵션을 꺼주면 된다.

RestTemplate restTemplate = new RestTemplate();
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setBufferRequestBody(false);

 

[오류 참고 사이트]

https://stackoverflow.com/questions/15781885/how-to-forward-large-files-with-resttemplate

 

How to forward large files with RestTemplate?

I have a web service call through which zip files can be uploaded. The files are then forwarded to another service for storage, unzipping, etc. For now the file is stored on the file system, then a

stackoverflow.com

 

+ Recent posts