Commit c029c27762695492900d25934d0cb3380cf04e07

Authored by 徐泉
1 parent 20c3076e
Exists in master

文件上传代码提交

cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java
... ... @@ -52,9 +52,18 @@ public class FileControl {
52 52 resultFile.setHref("");
53 53 fileList.add(resultFile);
54 54 return Result.genSuccessResult(fileList);
55   -
56 55 }
57 56  
  57 + @PostMapping("fileUpload2")
  58 + @ApiOperation("上传文件(重复文件会新增1)")
  59 + public Result fileUpload2(@RequestParam("imgFile") MultipartFile file, HttpServletRequest request) throws Exception {
  60 +
  61 + String ossPath = request.getHeader("ossPath");//oss的二级目录
  62 +
  63 + FileInfo fileInfo = fileService.upload(file, ossPath);
  64 +
  65 + return Result.genSuccess(fileInfo.getUrl());
  66 + }
58 67  
59 68 @PostMapping("fileUpload1")
60 69 @ApiOperation("上传文件")
... ...
cloud/fIle-center/src/main/java/com/sincere/file/model/result/Result.java
... ... @@ -39,4 +39,10 @@ public class Result<T> {
39 39 .setCode(0)
40 40 .setData(data);
41 41 }
  42 +
  43 + public static <T> Result<T> genSuccess(T data) {
  44 + return new Result<T>()
  45 + .setCode(200)
  46 + .setData(data);
  47 + }
42 48 }
... ...