content: package cn.xeblog.xechat.controller;
  
  import cn.xeblog.xechat.domain.vo.ResponseVO;
  import cn.xeblog.xechat.service.UploadService;
  import com.alibaba.fastjson.JSONObject;
  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 yanpanyi
   * @date 2019/03/27
   */
  @RestController
  @RequestMapping("/api/upload")
  public class UploadController {
  
      @Resource
      private UploadService uploadService;
  
      /**
       * 上传图片
       *
       * @param multipartFile
       * @return
       * @throws Exception
       */
      @PostMapping("/image")
      public ResponseVO uploadImage(@RequestParam("file") MultipartFile multipartFile) throws Exception {
          JSONObject jsonObject = new JSONObject();
          jsonObject.put("path", uploadService.uploadImage(multipartFile));
  
          return new ResponseVO(jsonObject);
      }
  }
  