From dbcaf1e87d685f3e41e9e13988fb75a8525cf46f Mon Sep 17 00:00:00 2001 From: jmal Date: Fri, 24 May 2024 16:57:58 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B7=BB=E5=8A=A0=E9=9D=9E=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E7=95=8C=E9=9D=A2=E4=B8=8B=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/rest/ShareController.java | 17 +++++++++++++---- .../clouddisk/interceptor/FileInterceptor.java | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/jmal/clouddisk/controller/rest/ShareController.java b/src/main/java/com/jmal/clouddisk/controller/rest/ShareController.java index 80d33d1f..247bfef1 100644 --- a/src/main/java/com/jmal/clouddisk/controller/rest/ShareController.java +++ b/src/main/java/com/jmal/clouddisk/controller/rest/ShareController.java @@ -31,10 +31,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; /** * @Description share @@ -152,6 +149,18 @@ public void publicPackageDownload(HttpServletRequest request, HttpServletRespons } } + @Operation(summary = "打包下载") + @GetMapping("/public/s/{fileId}/packageDownload/{filename}") + @LogOperatingFun(logType = LogOperation.Type.BROWSE) + public void publicPackageDownloadOne(HttpServletRequest request, HttpServletResponse response, @PathVariable String fileId, @PathVariable String filename) { + FileDocument fileDocument = fileService.getById(fileId); + if (fileInterceptor.isNotAllowAccess(fileDocument, request)) { + return; + } + List fileIdList = Collections.singletonList(fileId); + fileService.publicPackageDownload(request, response, fileIdList); + } + @Operation(summary = "显示缩略图") @GetMapping("/articles/s/view/thumbnail") @LogOperatingFun(logType = LogOperation.Type.BROWSE) diff --git a/src/main/java/com/jmal/clouddisk/interceptor/FileInterceptor.java b/src/main/java/com/jmal/clouddisk/interceptor/FileInterceptor.java index 9f7ee473..9d2f2880 100644 --- a/src/main/java/com/jmal/clouddisk/interceptor/FileInterceptor.java +++ b/src/main/java/com/jmal/clouddisk/interceptor/FileInterceptor.java @@ -182,7 +182,7 @@ private boolean fileAuthError(HttpServletRequest request, HttpServletResponse re private boolean validShareFile(HttpServletRequest request, Path uriPath, String shareKey) { FileDocument fileDocument = fileService.getById(shareKey); if (!isNotAllowAccess(fileDocument, request)) { - // 判断当前uri所属的文件是否为该分享的文件或其子文件 + // 判断当前uri所属的文件是否为已分享的文件或其子文件 FileDocument thisFile = getFileDocument(uriPath); if (thisFile.getPath().equals(fileDocument.getPath())) { return false;