【发布时间】:2020-09-07 07:33:01
【问题描述】:
我正在尝试通过创建 FormData 来发送音频/图像。
我当前的版本是:“react-native”:“0.59.10”,“axios”:“^0.19.2”,“react”:“16.8.3”。我正在我的安卓设备上测试我的应用程序
在发送 FormData 时每次都会出现“网络错误”。
这是我创建和发送帖子的方式;
let new_options = {
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': myAuthorization
}
};
const content = new FormData();
content.append('file', {
uri: 'file://' + attachment.path,
name: 'test',
type: attachment.type
});
content.append('ReportId', report_id);
content.append('MimeType', attachment.type);
try {
let res = await axios.post(myUrl, content, new_options);
}catch(err){
console.warn(err);
}
我已经尝试过更新 FLIPPER_VERSION 或编辑 ReactNativeFlipper.java,但我的项目中不存在这些东西,因为我使用的是旧版本的 react-native。我也试过删除调试文件夹。
【问题讨论】:
标签: react-native axios react-native-android