| package com.zy.crm.common.web; | 
|   | 
| 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 com.zy.crm.common.service.OssService; | 
|   | 
| 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)); | 
|     } | 
| } |