title: How to make Spring REST service to accept multipart file data sent by the Angular Controller?
body: <p>I'm trying to post a file from Angular controller to the backend. But Spring REST controller is receiving null.</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>myApp.controller('myCtrl', ['$scope', '$http', function($scope, $http){
               $scope.uploadFile = function(){
                      var formData=new FormData();
                      formData.append("file", $scope.myFile); 
                      alert("Hi");
                      $http({
                          method: 'POST',
                          url: 'upload', 
                          headers: {'Content-Type': undefined}, 
                          data: formData,
                          transformRequest: function(data, headersGetterFunction) {
                              return data;
                          }
                      }).success(function(data, status) {  
                           console.log('file is ' );
                           console.dir(data);
                      })
                      .error(function(data, status) {
                      });
                  }
           }]);
  </code></pre>
  
  <p><strong>Spring-REST Controller</strong></p>
  
  <pre><code> @RequestMapping(value="/upload", method=RequestMethod.POST)
           public @ResponseBody String upload(@RequestBody MultipartFile file)  {
                          System.out.println(file);
  }
  </code></pre>
  
  <p>I also tried with public @ResponseBody void uploadFile(MultipartHttpServletRequest request, HttpServletResponse response) but it's of no use. I have declared multipartResolver in the configuaration file too. Any Idea on this? I'm desperately looking for a solution.</p>