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

六月ゝ 毕业季﹏ 提交于 2019-12-19 07:09:20

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/40351429/formdata-how-to-get-or-set-boundary-in-multipart-form-data-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!