[DEV] 기록

[SpringBoot] RestTemplate을 통해 MultipartFile 보내는 방법

꾸준함. 2022. 3. 15. 16:06

개요

최근에 개발하는 프로젝트에서 파일 업로드 및 생성을 별도 인스턴스에서 진행하고 있어 RestTemplate을 사용해야 했습니다.

이번 게시글에서는 RestTemplate을 통해 MultipartFile을 보내는 방법을 짧게 공유해보겠습니다.

 

코드

 

1. RestTemplate을 통해 파일 보내는 코드


 

2. RestTemplate이 호출하는 컨트롤러


 

3. 적용했던 RestTemplate Config


 

참고

https://stackoverflow.com/questions/58344008/upload-multipartfiles-using-resttemplate

 

Upload MultipartFiles using RestTemplate

I have two end-points. One endpoint will receive files from Postman and should foreward the same files to another endpoint using RestTemplate. The 2nd endpoint is getting invoked, but no files.

stackoverflow.com

 

반응형