package com.xunwang.file.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.xunwang.commonutils.R;
import com.xunwang.file.util.MinioUtil;
import io.swagger.annotations.Api;
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;

@ApiSupport(author = "Long")
@Api("文件相关")
@RestController
@RequestMapping("/file")
public class FileUpload {

    @Resource
    private MinioUtil minioUtil;

    @PostMapping("/uploading")
    public R uploading(@RequestParam("file") MultipartFile file) {
        String upload = minioUtil.upload(file);
        return R.ok().data("url", upload);
    }
}
