我的python api有问题,它没有从我的spring boot api接收到图片
我认为问题来自我的springapi,因为当我通过邮递员将文件发送到pythonapi时,我得到了很好的答案
先谢谢你
/**
* headers
*/
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
/**
* body
*/
MultiValueMap<String, Object> body= new LinkedMultiValueMap<>();
body.add("photoAVerifier",new InputStreamResource(photoAVerifier.getInputStream(), photoAVerifier.getOriginalFilename()));
body.add("photoProfil",new InputStreamResource(photoAVerifier.getInputStream(),photoAVerifier.getOriginalFilename()));
HttpEntity<MultiValueMap<String, Object>> requestEntity
= new HttpEntity<>(body, headers);
/**
* request
*/
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ReponseApi> response = restTemplate
.exchange(urlApiCheckPhoto,HttpMethod.POST, requestEntity, ReponseApi.class);
目前没有回答
相关问题 更多 >
编程相关推荐