title: Multipart data sending got 408 Status
body: <p>guys. Need help with sending POST request with multipart-data.</p>
  
  <p>I have a method to create request on my client side. Here it is:</p>
  
  <pre><code>public void sendMultipart(String cmd , Employee emp) {
  
      CloseableHttpClient httpClient = HttpClients.createDefault();
      HttpPost uploadFile = new HttpPost(baseUrl + cmd);
  
      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      FileBody f = new FileBody(emp.getPhoto());
      try {
      StringBody s = new StringBody(emp.getLogin());
      builder.addPart("name", s);
      builder.addPart("file", f);
      } catch (UnsupportedEncodingException ex) {
          Logger.getLogger(RestTemplateRequester.class.getName()).log(Level.SEVERE, null, ex);
      }
      uploadFile.setHeader("Accept", "application/json");
          uploadFile.setHeader("Content-type", "application/json");
          uploadFile.setHeader("enctype","multipart/form-data");
          uploadFile.setHeader("accept-charset","UTF-8");
      //builder.addTextBody("field1", "yes", ContentType.TEXT_PLAIN);
      //builder.addBinaryBody(emp.getLogin(), emp.getPhoto(), ContentType.MULTIPART_FORM_DATA, "file");
      HttpEntity multipart = builder.build();
  
      uploadFile.setEntity(multipart);
  
      try {
          HttpResponse httpResponse =  httpClient.execute(uploadFile);
  
          int status = httpResponse.getStatusLine().getStatusCode();
          String str = httpResponse.getStatusLine().getReasonPhrase();
      } catch (IOException ex) {
          Logger.getLogger(RestTemplateRequester.class.getName()).log(Level.SEVERE, null, ex);
      }
  
  }
  </code></pre>
  
  <p>Also I have a method to handle request on my server side:</p>
  
  <pre><code>@RequestMapping(value = "photo", consumes = "multipart/form-data")
  public @ResponseBody
  void uploadFileHandler(@RequestParam("name") String name,
          @RequestParam("file") MultipartFile file) {
  
      if (!file.isEmpty()) {
          try {
              byte[] bytes = file.getBytes();
  
              // Create the file on server
              File serverFile = new File(name);
              BufferedOutputStream stream = new BufferedOutputStream(
                      new FileOutputStream(serverFile));
              stream.write(bytes);
              stream.close();
  
          } catch (Exception e) {
               e.getMessage();
          }
      }
  }
  </code></pre>
  
  <p>And in my context:</p>
  
  <pre><code>&lt;bean id="multipartResolver"
      class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
  
       &lt;!-- setting maximum upload size --&gt;
      &lt;property name="maxUploadSize" value="100000" /&gt;
  
  &lt;/bean&gt;
  </code></pre>
  
  <p>The problem which I have now  - is a 408 error "Request Time Out".
  My common aim is - send JSON with file to server. I so green with web services in java, so i got some troubles.
  Please, It will be great, if someone can give me a little advice. Thank you.</p>