For uploading files from angular to a Spring MVC REST WebService, people seem to be setting Content-Type : undefined header in the AJAX request.
What is the purpose of this type of content-type and is it required by Spring MultiPart?
$http.post(uploadUrl, fd, {
transformRequest : angular.identity,
headers : {
'Content-Type' : undefined
}
//...
}
It will reset the default header 'application/json' and let the browser fill in the correct Content-Type for us, along with a correct boundary parameter.
Setting in manually to 'multipart/form-data', for example, will fail to add the already mentioned boundary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With