react native:使用expo-image-picker上传图像,但不使用react-native-image-picker上传图像

时间:2020-05-29 04:59:41

标签: reactjs react-native react-native-image-picker

我尝试将图像上传到节点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"

没有上传图片。

我想念什么?

1 个答案:

答案 0 :(得分:0)

在android上使用react-native-image-picker时,应使用response.path代替response.uri来获取实际的文件路径。 check out docs

别忘了将file:///添加到从Android获得的response.path的开头。

response.uri不是永久性路径,上传时不能依赖它。