From 2c2e89725c5ceeeaa141e4810d675aa87f9269fe Mon Sep 17 00:00:00 2001 From: wangzhijiang <1358525938@qq.com> Date: Fri, 29 Mar 2024 17:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=AF=94=E4=BA=9A=E8=BF=AA-?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=AF=94=E4=BA=9A=E8=BF=AA=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BC=A0=E5=8F=82=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E6=8C=89=E7=85=A7=E4=BB=96=E4=BB=AC=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=B9=E6=88=90URL=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../split/service/impl/FileSpiltService.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java index c5945ff..4fbd643 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java @@ -61,6 +61,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import org.springframework.core.io.Resource; +import org.springframework.web.util.UriComponentsBuilder; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -221,19 +222,24 @@ public class FileSpiltService { try { // 根据byd传过来的文件下载路径获取文件。 RestTemplate restTemplate = new RestTemplate(); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - - // 创建MultiValueMap对象,用于存储请求参数 - MultiValueMap params = new LinkedMultiValueMap<>(); - String fileId = sarFileSplitInfoEO.getId(); - params.add("fileId", fileId); - - // 使用HttpEntity对象包装请求体和请求头 - HttpEntity> requestEntity = new HttpEntity<>(params, headers); +// HttpHeaders headers = new HttpHeaders(); +// headers.setContentType(MediaType.APPLICATION_JSON); +// +// // 创建MultiValueMap对象,用于存储请求参数 +// MultiValueMap params = new LinkedMultiValueMap<>(); +// String fileId = sarFileSplitInfoEO.getId(); +// params.add("fileId", fileId); +// +// // 使用HttpEntity对象包装请求体和请求头 +// HttpEntity> requestEntity = new HttpEntity<>(params, headers); +// +// // 发送POST请求并获取响应 +// ResponseEntity responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class); + Long fileId = Long.valueOf(sarFileSplitInfoEO.getId()); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(bydDownLoadFileUrl).queryParam("fileId", fileId); // 发送POST请求并获取响应 - ResponseEntity responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class); + ResponseEntity responseEntity = restTemplate.postForEntity(builder.toUriString(), null, byte[].class); // 获取文件流 splitFileIs = new ByteArrayInputStream(responseEntity.getBody()); }catch (Exception ex){