客户端将文件转换为流发送:
依赖的包:
org.apache.httpcomponents
httpclient
4.4
org.apache.httpcomponents
httpmime
4.4
import com.alibaba.fastjson.JSONObject;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public static void main(String[] args) throws IOException {
DataInputStream in = null;
OutputStream out = null;
HttpURLConnection conn = null;
JSONObject resposeTxt = null;
InputStream ins = null;
ByteArrayOutputStream outStream = null;
try {
// URL url = new URL("http://192.168.3.11:8081/mes-boot-doc/test/fileupload?fileName=shafei.xls");
URL url = new URL("http://localhost:8081/mes-boot-doc/test/fileupload?fileName=shafei.xls");
conn = (HttpURLConnection) u