我正在使用MultipartEntityBuilder发送多部分请求。我无法在服务器上检索addBinaryBody的内容。我正在服务器上使用Spring Rest Web服务检索内容。
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost("http://localhost:8080/PAautomation/upload");
InputStream fis = new FileInputStream(new File("abc.txt"));
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addBinaryBody("upfile", fis, ContentType.APPLICATION_OCTET_STREAM, "abc.txt");
//
HttpEntity entity = builder.build();
post.setEntity(entity);
HttpResponse response = client.execute(post);