From 6912730e9496f2e843482cfa1d441beb7e201be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Thu, 8 May 2025 16:20:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(RemoteFileService):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在RemoteFileService接口中添加upload方法用于文件上传 - 支持MultipartFile类型参数和MULTIPART_FORM_DATA媒体类型 - 返回R对象包含文件存储路径信息 --- .../admin/api/feign/RemoteFileService.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteFileService.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteFileService.java index 02120b00f..808d685f8 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteFileService.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteFileService.java @@ -1,10 +1,15 @@ package com.pig4cloud.pigx.admin.api.feign; import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants; +import com.pig4cloud.pigx.common.core.util.R; import feign.Response; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; /** * 文件读取 @@ -15,6 +20,21 @@ import org.springframework.web.bind.annotation.RequestParam; @FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.UPMS_SERVICE) public interface RemoteFileService { + /** + * 获取文件的方法 + * + * @param fileName 文件的名称 + * @return 响应对象,包含文件内容 + */ @GetMapping("/sys-file/oss/file") Response getFile(@RequestParam String fileName); + + /** + * 上传文件 + * + * @param file 资源 + * @return R(/ admin / bucketName / filename) + */ + @PostMapping(value = "/sys-file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + R upload(@RequestPart("file") MultipartFile file); }