title: 415 (Unsupported Media Type) when uploading files
body: <p>I want to upload files using angular js and spring boot.</p>
  
  <p>Here's my java controller</p>
  
  <pre><code>//upload Files
  
      @RequestMapping(value="/upload",headers=("content-type=multipart/*"), method=RequestMethod.POST)
      public @ResponseBody String handleFileUpload(@RequestParam("name") String name,@RequestParam("file") MultipartFile file){
          if (!file.isEmpty()) {
              try {
                  byte[] bytes = file.getBytes();
                  BufferedOutputStream stream =
                          new BufferedOutputStream(new FileOutputStream(new File(name)));
                  stream.write(bytes);
                  stream.close();
                  return "You successfully uploaded " + name + "!";
              } catch (Exception e) {
                  return "You failed to upload " + name + " =&gt; " + e.getMessage();
              }
          } else {
              return "You failed to upload " + name + " because the file was empty.";
          }
      }
  </code></pre>
  
  <p>Here's my form</p>
  
  <pre><code>&lt;section id="contact-info"&gt;
  
  
      &lt;section id="contact-page"&gt;
          &lt;div class="container"&gt;
              &lt;div class="center"&gt;        
  
                  &lt;p class="lead"&gt;Import reports&lt;/p&gt;
              &lt;/div&gt; 
              &lt;div class="row contact-wrap"&gt; 
                  &lt;div class="status alert alert-success" style="display: none"&gt;&lt;/div&gt;
                  &lt;form id="main-contact-form" class="contact-form" name="contact-form" method="POST" enctype="multipart/form-data" &gt;
                      &lt;div class="col-sm-5 col-sm-offset-1"&gt;
                          &lt;div class="form-group"&gt;
                              &lt;label&gt;name *&lt;/label&gt;
                              &lt;input type="text" name="name" class="form-control" required="required" ng-model="rap.name"&gt;
                          &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                              &lt;label&gt;file&lt;/label&gt;
                              &lt;input type="file" name="file" class="form-control" ng-model="rap.file"&gt;
                          &lt;/div&gt;                        
  
                          &lt;div class="form-group"&gt;
                              &lt;button type="submit"  class="btn btn-primary btn-lg"  ng-click="upload()"&gt;Import File&lt;/button&gt;
                          &lt;/div&gt;
  
                      &lt;/form&gt; 
              &lt;/div&gt;&lt;!--/.row--&gt;
          &lt;/div&gt;&lt;!--/.container--&gt;
      &lt;/section&gt;&lt;!--/#contact-page--&gt;
  </code></pre>
  
  <p>Here's my js controller</p>
  
  <pre><code>//Upload files
          $scope.upload=function(rap){
               $http.post('http://localhost:8080/upload?name='+$scope.rap.name+"file="+$scope.rap.file ,{
                       headers: { 'Content-Type': undefined },
                          transformRequest: angular.identity })
  
               .success(function(){
  
                   console.log('Post Succeded !');
               })
               .error(function(){
                   console.log('Post Failed .');
               });
          }
  </code></pre>
  
  <p>When i fill the form and i click on ImportFile , i have the error mentioned below .Any ideas?</p>