问题
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