title: Upload file using java MultipartEntityBuilder throws Content too long. What's an alternative?
body: <p>I'm trying to make a little utility that will synchronise data between two servers. Most of the calls there are REST calls with JSON, so I decided to use Apache HttpClient for this. 
  There is however a section where I need to upload a file. I'm trying to do this using the mutipart form data with the MutipartEntityBuilder but I encounter a Content too long problem. (I tried to gzip the contents of the file too, but I'm still going over the limit). </p>
  
  <p>Here's my java code: </p>
  
  <pre><code>        HttpPost request = new HttpPost(baseUrl+URL);
          MultipartEntityBuilder builder = MultipartEntityBuilder.create();
  
          //create upload file params
          builder.addTextBody("scanName", "Test upload");
          builder.addBinaryBody("myfile", f);
  
          HttpEntity params= builder.build();
  
          request.setEntity(params);
  
          request.addHeader("content-type","multipart/form-data");
  
          HttpResponse response = httpClient.execute(request);
  </code></pre>
  
  <p>Are there better atlernatives that I should be using for the file upload part? I'm also going to download the files from one of the server. Will I hit a similar issue when try to handle those responses? </p>
  
  <p>Is there something I'm doing wrong?</p>