|
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.*;
|
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.*;
|
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -25,6 +26,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
|
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
|
|
|
|
|
@@ -40,10 +43,11 @@ public class FileController {
|
|
|
|
|
|
@PostMapping("/upload")
|
|
@PostMapping("/upload")
|
|
@Operation(summary = "上传文件", description = "模式一:后端上传文件")
|
|
@Operation(summary = "上传文件", description = "模式一:后端上传文件")
|
|
- public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
|
|
|
|
|
+ public CommonResult<Map> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
|
MultipartFile file = uploadReqVO.getFile();
|
|
MultipartFile file = uploadReqVO.getFile();
|
|
|
|
+ long size = file.getSize();
|
|
String path = uploadReqVO.getPath();
|
|
String path = uploadReqVO.getPath();
|
|
- return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
|
|
|
|
|
+ return success(ImmutableMap.of("path",fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())),"size",size));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/presigned-url")
|
|
@GetMapping("/presigned-url")
|