diff --git a/oss-client/src/main/java/cn/axzo/oss/client/controller/WebFileController.java b/oss-client/src/main/java/cn/axzo/oss/client/controller/WebFileController.java index ed30958..37bb953 100644 --- a/oss-client/src/main/java/cn/axzo/oss/client/controller/WebFileController.java +++ b/oss-client/src/main/java/cn/axzo/oss/client/controller/WebFileController.java @@ -319,15 +319,31 @@ public class WebFileController { ServerFileDownloadDto dto = new ServerFileDownloadDto(); dto.setFileKey(fileUuId); ServerFileDownloadResponse result = fileService.getObject(dto, FileDownloadTypeEnum.STREAM_DOWNLOAD.getCode()); - try (OutputStream outputStream = response.getOutputStream(); InputStream inputStream = result.getFileStream()) { - // response.setContentType("application/octet-stream"); - response.setHeader("content-type","application/octet-stream"); - response.addHeader("Content-Disposition", "attachment;filename=" + result.getFileName() + "." + result.getFileFormat()); - // response.setCharacterEncoding("UTF-8"); - IOUtils.copy(inputStream, outputStream); - log.info("文件转换成功"); - } catch (Exception e) { - e.printStackTrace(); + + byte[] buff = new byte[1024]; + InputStream is = null; + OutputStream os = null; + try { + os = response.getOutputStream(); + is = result.getFileStream(); + int i = is.read(buff); + while (i != -1) { + os.write(buff, 0, buff.length); + os.flush(); + i = is.read(buff); + } + log.info("oss下载完成"); + } catch (IOException e2){ + e2.printStackTrace(); + } finally { + if (is != null) { + try { + is.close(); + //os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } } } diff --git a/oss-http-api/src/main/java/cn/axzo/oss/http/api/WebFileServiceApi.java b/oss-http-api/src/main/java/cn/axzo/oss/http/api/WebFileServiceApi.java index e746464..8af040a 100644 --- a/oss-http-api/src/main/java/cn/axzo/oss/http/api/WebFileServiceApi.java +++ b/oss-http-api/src/main/java/cn/axzo/oss/http/api/WebFileServiceApi.java @@ -20,7 +20,7 @@ import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; */ @FeignClient( name = "oss", - url = "http://localhost:9123" + url = "http://oss:9123" ) public interface WebFileServiceApi { /**