I'm using Java with HttpAsyncClient, and trying to make a post request to a server using multipart/form. There are two parameters: one is just a string, while the second one is a fie/byte array. When I need to perform requests with large size byte arrays, I get the following exception: org.apache.http.ContentTooLongException: Content length is too long.
Is there any way to overcome this issue? How could I make a large sized request with multipart/form using Java and this entity?
Here is some of my code:
final HttpPost post = new HttpPost(uri);
final HttpEntity entity = MultipartEntityBuilder.create()
.addTextBody("name", fileName).addBinaryBody("file", rawContent, ContentType.APPLICATION_OCTET_STREAM, fileName)
.build();
post.setEntity(entity);
return client.execute(post, null);
Where rawContent is just a byte array.