From 56b8b84689ccf5389ee02814bcb8bfe407f05a87 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 28 四月 2026 11:09:24 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro
---
src/main/java/com/ruoyi/project/common/CommonController.java | 35 +++++++++++++++++++++++++++++------
1 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/common/CommonController.java b/src/main/java/com/ruoyi/project/common/CommonController.java
index bf7bda4..9ee3c93 100644
--- a/src/main/java/com/ruoyi/project/common/CommonController.java
+++ b/src/main/java/com/ruoyi/project/common/CommonController.java
@@ -128,15 +128,32 @@
// }
@PostMapping({"/upload"})
@Operation(summary = "鏂囦欢涓婁紶")
- public R upload(@RequestParam("files") List<MultipartFile> files) throws Exception {
- return R.ok(storageBlobService.upload(files));
+ public R upload(@RequestParam("files") List<MultipartFile> files) {
+ return R.ok(storageBlobService.upload(files, false));
}
+ /**
+ * 鍏叡鏂囦欢涓婁紶
+ * 姝ゆ帴鍙d笂浼犵殑鏂囦欢姘镐箙鏈夋晥锛屾厧鐢�
+ */
+ @PostMapping({"/public/upload"})
+ @Operation(summary = "鏂囦欢涓婁紶")
+ public R publicUpload(@RequestParam("files") List<MultipartFile> files) {
+ return R.ok(storageBlobService.upload(files, true));
+ }
@GetMapping("/download/{fileName}")
@Anonymous
- public void download(@PathVariable String fileName, @RequestParam("token") String token, HttpServletResponse response) throws Exception {
- File file = storageBlobService.getFileByToken(fileName, token);
+ public void download(@PathVariable String fileName,
+ @RequestParam(value = "token", required = false) String token,
+ @RequestParam(value = "publicKey", required = false) String publicKey,
+ HttpServletResponse response) throws Exception {
+ File file;
+ if (publicKey != null) {
+ file = fileUtil.compressFile(storageBlobService.getPublicFile(fileName, publicKey));
+ } else {
+ file = fileUtil.compressFile(storageBlobService.getFileByToken(fileName, token));
+ }
String originalFileName = storageBlobService.getDownloadFileName(fileName);
String encodedFileName = URLEncoder.encode(originalFileName, StandardCharsets.UTF_8.name()).replace("+", "%20");
response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + encodedFileName);
@@ -147,8 +164,14 @@
@GetMapping("/preview/{fileName}")
@Anonymous
public ResponseEntity<FileSystemResource> preview(@PathVariable String fileName,
- @RequestParam("token") String token) throws Exception {
- File file = fileUtil.compressFile(storageBlobService.getFileByToken(fileName, token));
+ @RequestParam(value = "token", required = false) String token,
+ @RequestParam(value = "publicKey", required = false) String publicKey) throws Exception {
+ File file;
+ if (publicKey != null) {
+ file = fileUtil.compressFile(storageBlobService.getPublicFile(fileName, publicKey));
+ } else {
+ file = fileUtil.compressFile(storageBlobService.getFileByToken(fileName, token));
+ }
String contentType = Files.probeContentType(file.toPath());
ContentDisposition contentDisposition = ContentDisposition.inline()
--
Gitblit v1.9.3