我正在使用Apache HttpClient执行多部分请求来上传文件,但在第三次请求后它不起作用。
这是我的代码:
HttpClient httpClient = HttpClientBuilder.create().build();
Map<String, String> requestParams = new HashMap<>();
requestParams.put("param1", "myrequestparam");
String url = UPLOAD_URL + "?param1=" + myRequestParam;
HttpEntity entity = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.addBinaryBody("file", file, ContentType.MULTIPART_FORM_DATA, "file")
.build();
HttpPost request = new HttpPost(url);
request.setEntity(entity);
try {
httpClient.execute(request);
} catch (IOException e) {
throw new InternalServerErrorException(e);
}
它正在执行多次,罚款两次以上,但第三次没有任何事情发生。
我做错了什么?