无关风月
21 小时以前 7cab5bda99ca42188bc15b2dae7d1fa4d1833fd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.ruoyi.admin.controller;
 
import com.ruoyi.admin.utils.TencentCosUtil;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import javax.annotation.Resource;
 
/**
 * @author HJL
 * @version 1.0
 * @since 2024-05-30 9:27
 */
@RestController
@RequestMapping("/oss")
@Api(tags = "公共-文件上传")
public class OssController {
 
    @Resource
    private TencentCosUtil tencentCosUtil;
 
    @PostMapping("/upload")
    @ApiOperation(value = "文件上传", tags = "公共-文件上传")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "文件", name = "file", dataType = "MultipartFile", required = true)
    })
    public R<String> upload(@RequestParam("file") MultipartFile file) {
        String s = tencentCosUtil.upLoadFile(file);
        return R.ok(s, s);
    }
 
}