HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
paramMap.add("file", new FileSystemResource(file));
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(paramMap, headers);
restTemplate.postForObject(url,httpEntity, String.class);
RestTemplate发送文件
young
483
2021-10-17