【问题标题】:react native : image is uploading using expo-image-picker but not uploading using react-native-image-pickerreact native:图片正在使用 expo-image-picker 上传,但不使用 react-native-image-picker 上传
【发布时间】:2020-09-16 14:43:09
【问题描述】:

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

没有上传图片。

我错过了什么?

【问题讨论】:

  • 请帮我怎么做?
  • 我唯一能告诉你的是,expo-image-picker 就像一个魅力,而 react-native-image-picker 很糟糕,我什至不能让它运行,因为它只会抛出错误。

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


【解决方案1】:

当你在android上使用react-native-image-picker时,你应该使用response.path而不是response.uri来获取实际的文件路径。 check out docs

不要忘记将file:/// 添加到您从android 获得的response.path 的开头。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 2016-12-08
    • 2020-03-02
    • 2020-11-04
    • 2021-09-28
    • 2020-04-09
    • 1970-01-01
    相关资源
    最近更新 更多