diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java index 0ff91553f..c348af414 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java @@ -43,25 +43,24 @@ public class SplitFileController { splitIndex = fileUrl.lastIndexOf("/"); } String fileName = fileUrl.substring(splitIndex + 1); +// response.setHeader("Content-Disposition", +// "attachment; filename=\""+fileName+"\""); response.setHeader("Content-Disposition", - "attachment; filename=\""+fileName+"\""); - response.setHeader("Content-Disposition", - "attachment; filename=\""+ SplitFileUtils.encodeFileName(fileName, request) +"\""); + "attachment; filename=\"" + SplitFileUtils.encodeFileName(fileName, request) + "\""); response.setContentType("application/force-download"); - try(OutputStream os = response.getOutputStream(); - /*FileInputStream fis = new FileInputStream(fileUrl);*/) { - if (CosBootUtil.doesObjectExist(fileUrl)) { - InputStream fis = CosBootUtil.download(fileUrl); + if (CosBootUtil.doesObjectExist(fileUrl)) { + try (OutputStream os = response.getOutputStream(); + InputStream fis = CosBootUtil.download(fileUrl)) { int len = 0; while ((len = fis.read()) != -1) { os.write(len); } os.flush(); + } catch (FileNotFoundException e) { + throw new JeroBootException("文件不存在"); + } catch (IOException e) { + throw new JeroBootException("文件不存在"); } - } catch (FileNotFoundException e) { - throw new JeroBootException("文件不存在"); - } catch (IOException e) { - throw new JeroBootException("文件不存在"); } }