我正在尝试使用 Expo 将我的手机上的图片上传到 Firebase。我从图片中得到一个 uri,但不知道如何转换它,我可以将它上传到 Firebase?
_pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
});
if (!result.cancelled) {
console.log('device URL: w',result.uri);
this.setState({ image: result.uri });
this.uploadImage(result.uri).then(resp =>{
alert('success')
}).catch(err=>{
console.log(err)
})
}
};
当我记录 result.uri 我得到:
file:///var/mobile/Containers/Data/Application/1E5612D6-ECDB-44F4-9839-3717146FBD3E/Library/Caches/ExponentExperienceData/%2540anonymous%252FexpoApp-87f4a5f5-b117-462a-b147-cab242b0a916/ImagePicker/45FA4A7- C174-4BC9-B35A-A640049C2CCB.jpg
如何将其转换为适用于 firebase 的格式?