FormData how to get or set boundary in multipart/form-data - Angular

Pablo picture Pablo · Oct 31, 2016 · Viewed 13.7k times · Source

I have a mini app, where I have to post a form data to an endpoint from browser.

This is my post:

var formData = new FormData();
formData.append('blobImage', blob, 'imagem' + (new Date()).getTime());

return $http({
  method: 'POST',
  url: api + '/url',
  data: formData,
  headers: {'Content-Type': 'multipart/form-data'}
})

Boundaries seems to be added by formData to the parameter, however, I cannot get it to send in the header, how should I done?

Answer

Pablo picture Pablo · Nov 1, 2016

Well, seems that the headers ContentType should be undefined, in order to add the correct boundaries