Posting mutipart/form-data with RxJS ajax

别等时光非礼了梦想. 提交于 2019-12-11 05:53:00

问题


Is it possible to post multipart/form-data with RxJS Ajax observable? I tried to do so by setting Content-Type in ajax settings object like so.

import { ajax } from 'rxjs/observable/dom/ajax';

let data = {
  ad = 'ad_id',
  image = <HTML5 File object>
}

let settings = {
  url: '/some-url',
  body: data,
  method: 'post',
  headers: {
    'Content-Type': 'multipart/form-data; boundary=---------2e50046',
    ...
  }
  ...
}

And used ajax(settings) to post the form

However, it does not seem to work when sent to backend server. I use Django Rest Framework in the backend.

I hope you can help me out on this.

来源:https://stackoverflow.com/questions/43151306/posting-mutipart-form-data-with-rxjs-ajax

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