我尝试将图像上传到节点js服务器,它可以与expo-image-picker一起正常工作,但不能在react-native-image-picker中工作
这样,我注意到expo和react-native CLI之间的URI不同
通过使用expo-image-picker,URI为
"uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540satya89310%252Fembteen/ImagePicker/a05bf1a7-cef8-4cef-b73d-8fc330007927.jpg",
这工作正常,并且图像正在节点js服务器上上传
但是通过react-native-image-picker,URI是
"uri": "content://com.embteen.provider/root/storage/emulated/0/Pictures/images/image-12b4f263-5747-4404-a41e-1acf8926ea24.jpg"
没有上传图片。
我想念什么?
答案 0 :(得分:0)
在android上使用react-native-image-picker
时,应使用response.path
代替response.uri
来获取实际的文件路径。 check out docs
别忘了将file:///
添加到从Android获得的response.path
的开头。
response.uri
不是永久性路径,上传时不能依赖它。