title: Can't POST multipart/form-data from React to Spring
body: <p>I want to take file-uploads from React and sending it to springboot.
  I am trying to post from React FormData that will contain the key-value pair of the name of the file and a file which will be XML. So when I try to post the FormData to my backend which is Springboot, it returns:</p>
  
  <pre><code>.w.s.m.s.DefaultHandlerExceptionResolver : Resolved 
  [org.springframework.web.HttpMediaTypeNotSupportedException: 
  Content type 'application/json;charset=UTF-8' not supported]
  </code></pre>
  
  <p>and here is my React Code:</p>
  
  <pre><code>handleSubmit = (e) =&gt; {
  e.preventDefault();
  console.log(this.state.file[0].name);
  const formData = new FormData();
  var i = this.state.file.length;
  console.log(i);
  for (var j = 0; j &lt; i; j++) {
      formData.append(this.state.file[j].name, this.state.file[j])
  }
  for (var pair of formData.entries()) {
      console.log(pair[0] + ',' + pair[1]);
  }
  
  Axios.post('http://localhost:8080/upload', {
      file:formData
    })
    .then(response=&gt;{
        console.log(response)
    })
    ;
  </code></pre>
  
  <p>And here is my Springboot Controller:</p>
  
  <pre><code>@CrossOrigin
  @RequestMapping(value = "/upload", consumes = "multipart/form-data", method = RequestMethod.POST)
  public String upload(@RequestParam("file") MultipartFile[] file) throws IOException {
      System.out.println(file.length);
      for(MultipartFile temp : file) {
          System.out.println(temp.getOriginalFilename());
          System.out.println(temp.getSize());
          File converted = new File(temp.getOriginalFilename());
          temp.transferTo(converted);
          System.out.println(converted.getTotalSpace());
      }
          return "blah";
  
  }
  </code></pre>
  
  <p>I have already tried specifying multipart/form-data in the header of the Axios post request but it did not seem to work.
  Is the problem in my request or is it my controller?
  Please let me know if you have any ideas, I've been banging my head against the wall for a couple hours trying to fix this.</p>