title: Spring Web Reactive client
body: <p>I'm trying to use the Spring Reactive WebClient to upload a file to a spring controller. The controller is really simple and looks like this:</p>
  
  <pre><code>@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
  public ResponseEntity&lt;String&gt; uploadFile(
          @RequestParam("multipartFile") MultipartFile multipartFile,
          @RequestParam Map&lt;String, Object&gt; entityRequest
          ) {
      entityRequest.entrySet().forEach(System.out::println);
      System.out.println(multipartFile);
      return ResponseEntity.ok("OK");
  }
  </code></pre>
  
  <p>When I use this controller with cURL everything works fine</p>
  
  <pre><code>curl -X POST http://localhost:8080/upload -H 'content-type: multipart/form-data;' -F fileName=test.txt -F randomKey=randomValue -F multipartFile=@document.pdf
  </code></pre>
  
  <p>The multipartFile goes to the correct parameter and the other parameters go in to the Map.</p>
  
  <p>When I try to do the same from the WebClient I get stuck. My code looks like this:</p>
  
  <pre><code>    WebClient client = WebClient.builder().baseUrl("http://localhost:8080").build();
  
      MultiValueMap&lt;String, Object&gt; map = new LinkedMultiValueMap&lt;&gt;();
      map.set("multipartFile", new ByteArrayResource(Files.readAllBytes(Paths.get("/path/to/my/document.pdf"))));
      map.set("fileName", "test.txt");
      map.set("randomKey", "randomValue");
      String result = client.post()
              .uri("/upload")
              .contentType(MediaType.MULTIPART_FORM_DATA)
              .syncBody(map)
              .exchange()
              .flatMap(response -&gt; response.bodyToMono(String.class))
              .flux()
              .blockFirst();
      System.out.println("RESULT: " + result);
  </code></pre>
  
  <p>This results in an 400-error</p>
  
  <pre><code>{
    "timestamp":1510228507230,
    "status":400,
    "error":"Bad Request",
    "message":"Required request part 'multipartFile' is not present",
    "path":"/upload"
  }
  </code></pre>
  
  <p>Does anyone know how to solve this issue?</p>