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?
The boundary is included to separate name/value pair in the multipart/form-data . The boundary parameter acts like a marker for each pair of name and value in the multipart/form-data. The boundary parameter is automatically added to the Content-Type in the http (Hyper Text Transfer Protocol) request header.
multipart/form-data contains boundary to separate name/value pairs. The boundary acts like a marker of each chunk of name/value pairs passed when a form gets submitted. The boundary is automatically added to a content-type of a request header.
The boundary is specified like this: Content-Type: multipart/form-data; boundary=AaB03x . So, without a proper content-type, you almost can't have true multipart/form-data.
Well, seems that the headers ContentType should be undefined, in order to add the correct boundaries
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