react-native - Android 上的 Expo 和 React Native Axios 文件发布问题 - 无法从 ReadableNativeMap 投射 uri 的值
问题描述
const uri = await getFileInfo(fileName);
const body = new FormData();
body.append('file', {
uri,
name: 'helloworld',
type: 'image/jpeg'
});
// process current image
await axios.post(`${MEDIA_URL}/raw`, body, headers);
上面的代码在 IOS 上运行良好,但在 Android 上我得到以下内容:
java.lang.ClassCastException:uri 的值不能从 ReadableNativeMap 转换为 String
没有明显的迹象表明它来自哪里,但 URI 对象看起来像这样:
Object {
"exists": true,
"isDirectory": false,
"modificationTime": 1560600287,
"size": 2898352,
"uri": "file:///data/user/0/com.project.name/files/ExperienceData/%2540project%252Fproject-name/_64_4/838f7807-bb53-4017-bd5a-f8f506292ad3.jpg",
}
有什么迹象表明这是什么原因造成的?
解决方案
推荐阅读
- swift - Build error: Must call a designated initializer of the superclass 'UIControl'
- javascript - Why is it saying that calcAverage is not a function, when it is
- c - Sleep system call force a context switch? - C
- node.js - In nodejs, Find sub array in array
- python - apply function to pandas column based on list of dictionaries
- java - Execute Hadoop Command from Java app using jsch remotely
- flutter - How can send value from class to main class flutter?
- c# - 如何在 OnConfiguring 方法中从 app.config 或 appsettings.json 获取连接字符串
- javascript - DOM 的元素是如何工作的?它是一种指针吗?
- javascript - EventListener 中的类型错误