mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	【功能新增】前端文件直传
This commit is contained in:
		| @@ -2,19 +2,19 @@ package cn.iocoder.yudao.module.infra.controller.app.file; | ||||
|  | ||||
| import cn.hutool.core.io.IoUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateReqVO; | ||||
| import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO; | ||||
| import cn.iocoder.yudao.module.infra.controller.app.file.vo.AppFileUploadReqVO; | ||||
| import cn.iocoder.yudao.module.infra.service.file.FileService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import jakarta.annotation.Resource; | ||||
| import jakarta.validation.Valid; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| @Tag(name = "用户 App - 文件存储") | ||||
| @@ -35,4 +35,16 @@ public class AppFileController { | ||||
|         return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/presigned-url") | ||||
|     @Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器") | ||||
|     public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception { | ||||
|         return success(fileService.getFilePresignedUrl(path)); | ||||
|     } | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件") | ||||
|     public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) { | ||||
|         return success(fileService.createFile(createReqVO)); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 卢越
					卢越