From 41936bd595f36bb097fca6214a9cc5cb324ae94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E8=B6=85?= <1162714483@qq.com> Date: Sun, 11 Jul 2021 17:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=80=BB=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=92=8C?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qiwenshare/file/service/FiletransferService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/qiwenshare/file/service/FiletransferService.java b/src/main/java/com/qiwenshare/file/service/FiletransferService.java index e040e76..96c757c 100644 --- a/src/main/java/com/qiwenshare/file/service/FiletransferService.java +++ b/src/main/java/com/qiwenshare/file/service/FiletransferService.java @@ -15,6 +15,7 @@ import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.qiwenshare.common.operation.FileOperation; import com.qiwenshare.common.util.DateUtil; import com.qiwenshare.common.util.FileUtil; @@ -135,7 +136,7 @@ public class FiletransferService implements IFiletransferService { downloadFile.setFileUrl(fileBean.getFileUrl()); downloadFile.setFileSize(fileBean.getFileSize()); - + httpServletResponse.setContentLengthLong(fileBean.getFileSize()); downloader.download(httpServletResponse, downloadFile); } else { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -147,9 +148,9 @@ public class FiletransferService implements IFiletransferService { String staticPath = PathUtil.getStaticPath(); String tempPath = staticPath + "temp" + File.separator; - File tempFile = new File(tempPath); - if (!tempFile.exists()) { - tempFile.mkdirs(); + File tempDirFile = new File(tempPath); + if (!tempDirFile.exists()) { + tempDirFile.mkdirs(); } FileOutputStream f = null; @@ -213,6 +214,8 @@ public class FiletransferService implements IFiletransferService { Downloader downloader = ufoFactory.getDownloader(StorageTypeEnum.LOCAL.getStorageType()); DownloadFile downloadFile = new DownloadFile(); downloadFile.setFileUrl("temp" + File.separator+userFile.getFileName() + ".zip"); + File tempFile = FileOperation.newFile(PathUtil.getStaticPath() + downloadFile.getFileUrl()); + httpServletResponse.setContentLengthLong(tempFile.length()); downloader.download(httpServletResponse, downloadFile); String zipPath = PathUtil.getStaticPath() + "temp" + File.separator+userFile.getFileName() + ".zip"; File file = new File(zipPath);