title: How to upload a file using Apache HttpPost
body: <p>I've got a curl call like this:</p>
  
  <pre><code>curl -i -X POST -H "Content-Type: multipart/form-data" -F "file=@data_test/json_test.json" http://domain.com/api/upload_json/
  </code></pre>
  
  <p>All I need to do is a Java implementation for this call. I've already made this code, but the file, which appears to server, seems to be null.</p>
  
  <pre><code>public static void uploadJson(String url, File jsonFile) {
      try {
          HttpPost request = new HttpPost(url);
          EntityBuilder builder = EntityBuilder
                  .create()
                  .setFile(jsonFile)
                  .setContentType(ContentType
                          .MULTIPART_FORM_DATA)
                  .chunked();
          HttpEntity entity = builder.build();
          request.setEntity(entity);
          HttpResponse response = getHttpClient().execute(request);
          logger.info("Response: {}", response.toString());
      } catch (IOException e) {
          logger.error(e.getMessage());
      }
  }
  </code></pre>
  
  <p>What is the proper way to build this request?</p>