正如标题所说,我正在尝试以 react native 将图像上传到 firebase。我正在为此使用react-native-image-picker
和firebase
模块。我的代码如下:(为清楚起见,仅包括“主要”部分)
import ImagePicker from 'react-native-image-picker';
...
//called on pressing a button
onChooseImagePress = async () => {
let result = await ImagePicker.open({ //error occurs here
takePhoto: true,
useLastPhoto: true,
chooseFromLibrary: true
});
if (!result.cancelled) {
this.uploadImage(result.uri, "test-image")
.then(() => {
Alert.alert("Success");
})
.catch((error) => {
Alert.alert(error);
});
}
}
uploadImage = async (uri, imageName) => {
const response = await fetch(uri);
const blob = await response.blob();
var ref = firebase.storage().ref('images').child("userName/" + imageName);
return ref.put(blob);
}
....
问题:
我收到此错误:undefined is not a function
。这是相同的屏幕截图:
我不确定它甚至意味着什么,因为它ImagePicker
有一个open
功能。请注意,我已经提供了所需的权限。因此,这不是问题。请帮我解决这个问题。谢谢...