[Spring] RestTemplate으로 MultipartFile 단일 업로드 HTTP 멀티 파트 요청이란? HTTP 클라이언트는 HTTP 멀티 파트 요청을 구성하여 텍스트 또는 바이너리 파일을 서버로 보낼 수 있다. 주로 파일 업로드에 사용된다. 다른 예시로 첨부 파일과 함께 이메일을 보낼 때 사용하기도 한다. private void callFileUpdateApi(int contentId, MultipartFile file) { //RestTemplate을 이용한 단일 파일 업로드 HttpHeaders headers = new HttpHeaders(); //헤더와 본문이 있는 HttpEntity를 만든다. headers.setContentType(MediaType.MULTIPART_FORM_DATA); //헤더값을 설정해주면 RestTemplate은 일부 메타 데이터와 함께 파.. 2021. 10. 26. 이전 1 다음