#
mrzhssss
2022-04-18 cd91d368ecceb75d93e9a0099507371ccc38d749
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
package zy.cloud.wms.common.web;
 
import zy.cloud.wms.common.service.OssService;
import com.core.common.Cools;
import com.core.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import java.io.IOException;
import java.io.InputStream;
 
/**
 * Created by vincent on 2020/10/7
 */
@RestController
public class UploadController {
 
    @Autowired
    private OssService ossService;
 
    @PostMapping("/upload.action")
    public R upload(MultipartFile file) {
        String suffix = file.getName().substring(file.getName().lastIndexOf(".") + 1);
        InputStream inputStream = null;
        try {
            inputStream = file.getInputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String upload=ossService.upload(inputStream,suffix);
        return R.ok(Cools.add("url", upload));
    }
}