我正在尝试将图像从我的本机应用程序上载到Firebase,但是我遇到此错误已有2天了,我也没有找到原因,我之前也做过这件事,但是这次是引起这个问题的。 这是我的代码,
_pickImageFront = async () => {
let pickerResult = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
base64:true,
quality:1.0
});
if(!pickerResult.cancelled){
//this.setState({userImage: pickerResult.uri, imageResult : pickerResult, imageSelected: true});
this.uploadImage(pickerResult.uri,'front-image')
.then(()=>{
alert('success');
})
.catch((error)=>{
alert(error)
});
}
}
uploadImage = async(uri,imageName) => {
const response = await fetch(uri);
const blob =await response.blob();
var ref = fire.storage().ref().child('images/'+imageName);
return ref.put(blob);
}
//render method is here
<TouchableOpacity onPress={this._pickImageFront}>
<Image
source={ImageIcon}
style={{width:wp('10%'),
height:hp('5%')}}/>
</TouchableOpacity>