我正在尝试从博览会相机中保存图片。之后我会把这张照片发给cloudinary。因此我需要base64属性。但我有一个问题。
takePictureAndCreateAlbum = async () => {
const { uri } = await this.camera.takePictureAsync({
base64: true
}).then(data => {
return (
this.setState({
data
}),
console.log("data", data)
)
}).catch(err => {
throw error;}
)
const asset = await MediaLibrary.createAssetAsync(uri);
MediaLibrary.createAlbumAsync('Expo', asset)
.then(() => {
Alert.alert('Album created!')
})
.catch(error => {
Alert.alert('An Error Occurred!')
});
this.sendCloudinary(this.state.data)
};
当我尝试保存图片时,出现以下错误:
可能的未处理承诺拒绝(id:0):
TypeError:无法读取未定义的属性“uri”
我检查了另一个问题和答案。但我没有找到解决方案。我该如何解决?