如何解决在本地范围之外无法访问JS异步返回
我感谢社区可以提供的任何帮助!我有一个React-native类组件,其getPathForFirebaseStorage方法被另一个方法调用。但是,无论何时调用以下方法,它都会返回:
{"_U": 0,"_V": 0,"_W": null,"_X": null}
getPathForFirebaseStorage中的console.log返回所需的实际本地设备路径:
/storage/emulated/0/DCIM/Camera/IMG_20200726_091113.jpg
那么关于如何改进getPathForFirebaseStorage以便返回结果可以在其自身本地范围之外访问的任何想法?方法如下:
getPathForFirebaseStorage = async (uri) => {
const stat = await RNFetchBlob.fs.stat(uri)
console.log(stat.path)
return stat.path
}
以下是调用getPathForFirebaseStorage的方法:
handleLibraryPhoto = () => {
const options = {
storageOptions: {
path: 'images',}
}
ImagePicker.launchImageLibrary(options,(response) => {
if (response.didCancel) {
console.log('User cancelled image picker')
} else if (response.error) {
console.log('ImagePicker Error: ',response.error)
} else if (response.customButton) {
console.log('User tapped custom button: ',response.customButton)
} else {
const source = {uri: response.uri};
const androidPath = this.getPathForFirebaseStorage(source.uri);
this.setState({image: androidPath});
console.log(this.state.image);
}
})
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)