I'm trying to send file on my rest service. I'm using apache httpcomponents 4.3.
It works, but it use about 600 MB
. Always, if file 200 KB
or 15 GB
it use 600 MB
of Ram.
If I remove addPart
- memory is OK.
So, why file sending get so much memory?
This is my code
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
CloseableHttpClient client = clientBuilder.build();
HttpPost post = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addTextBody("jsonData", gson.toJson(dto));
builder.addPart("file", new FileBody(file, ContentType.APPLICATION_OCTET_STREAM));
post.setEntity(builder.build());
HttpResponse response = client.execute(post);