【发布时间】:2019-10-01 14:50:12
【问题描述】:
我获得了 blob url,并且能够为每个 blob url 创建一个文件并将它们发送到后端,但是,我还需要传递一堆不同对象的属性。 (这些属性与文件完全无关)
问题是我无法将它们一起发送到后端。当然,我尝试只发送一个对象并将我的表单数据(文件)作为对象属性传递,但它不起作用。我也试过 content-type: multipart/form-data。
请不要担心语法错误。
export const sendObjectAndFile = (myObj, file) => {
return function(dispatch) {
let form = new FormData();
form.append('pdf file', file)
return fetch(URL, {
method: "POST",
credentials: 'include',
body: myObj /* If I pass only form or only myObj that works, however, how can I send them together */
}).then(response =>
if (response.success) {
} else {
}
});
}
为了了解我如何处理支持的 blob url(我假设我只传递了文件)
var myFile = Request.Files;
【问题讨论】: