React Native,在使用 Axios 发布 FormData 时出现网络错误

React Native, getting network error while posting FormData with Axios

我正在尝试通过创建 FormData 来发送 audio/image。

我当前的版本是:“react-native”:“0.59.10”,“axios”:“^0.19.2”,“react”:“16.8.3”。我正在 android 设备

上测试我的应用

发送 FormData 时每次都出现“网络错误”。

这是我创建和发送的方式post;

  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,因此我的项目中存在 none 这些东西。我也试过删除调试文件夹。

搞清楚了,问题是错误的 MimeTypes 引起的。