Content-Type undefined target in AngularJS FileUpload

To download files from angular to Spring MVC REST WebService, people seem to set Content-Type: an undefined header in an AJAX request.

What is the purpose of this type of content and is it required for Spring MultiPart?

$http.post(uploadUrl, fd, {
  transformRequest : angular.identity,
  headers : {
   'Content-Type' : undefined
  }
//...
}
+5
source share
1 answer

It will reset the default header to 'application / json' and let the browser fill in the correct Content-Type for us, as well as the correct border parameter.

For example, manual installation for "multipart / form-data" will not be able to add the already specified border.

+5
source

Source: https://habr.com/ru/post/1666584/


All Articles