一)引入okhttp3的jar
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.0.0</version>
</dependency>
二)提供一个上传服务接口,文件类型为MultipartFile
package com.oysept.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.oysept.vo.FileVO;
@RestController
public class MultipartUploadController {
/**
* 该方式是二进制流操作, 适合所有类型文件上传
* 访问地址: http://localhost:8080/okhttp3/post/multipartFile
* 请求方式: POST
* 传参方式: multipart
* @param da