From b6386a8c9e98a41a11a95baa412a33fc6afcd40a Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Fri, 7 Mar 2025 14:41:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E5=86=99=E7=9C=9F?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E7=89=B9=E6=AE=8A=E4=BA=A7=E5=93=81=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/file/FileController.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/file/FileController.java b/src/main/java/com/cultural/heritage/controller/file/FileController.java index 511ca0f..2af7b94 100644 --- a/src/main/java/com/cultural/heritage/controller/file/FileController.java +++ b/src/main/java/com/cultural/heritage/controller/file/FileController.java @@ -11,6 +11,7 @@ import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.enums.FileUploadBizEnum; import com.cultural.heritage.service.file.IHweiYunOBSService; import com.cultural.heritage.service.user.UserService; +import com.google.gson.Gson; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -25,6 +26,8 @@ import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; @RestController @RequestMapping("/file") @@ -117,7 +120,7 @@ public class FileController { @PostMapping("/upload/single") @Operation(summary = "单独文件上传", description = "参数:file,文件对象(multipartFile),权限:所有人,方法名:uploadServerFile") - public BaseResponse uploadSingleServerFile(@RequestPart("file")MultipartFile multipartFile, HttpServletRequest request) { + public Object uploadSingleServerFile(@RequestPart("file")MultipartFile multipartFile, HttpServletRequest request) { // // 校验文件 validFile(multipartFile, null); @@ -137,7 +140,17 @@ public class FileController { } //返回可访问地址 String url = iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath); - return ResultUtils.success(url); + + Map data = new HashMap<>(); + data.put("url", url); + + // 创建最终的响应对象 + Map response = new HashMap<>(); + response.put("errno", 0); + response.put("data", data); + Gson gson = new Gson(); + + return gson.fromJson(gson.toJson(response), Object.class); }