问题描述
我想我忘记了一个步骤,因为当我尝试将图片上传到 firebase 存储时,我可以在 console.log 上看到路径,但是当我使用 putfile 上传时,出现此错误:
错误:[storage/file-not-found] 指定的本地文件在设备上不存在。 NativeFirebaseError: [storage/file-not-found] 指定的本地文件在设备上不存在。
也是我的功能:
unction GetPictures() {
const reference = storage().ref("PicturesUsers/Avatar.png");
const [response,setResponse] = React.useState();
return (
<SafeAreaView>
{response && (
<View style={styles.image}>
<Image
style={{ width: 200,height: 200,borderRadius: 200 }}
source={{ uri: response.uri }}
/>
</View>
)}
<View style={{ marginTop: -70 }}>
<Icon
name="camera-retro"
size={30}
color="#5DC1D3"
onPress={async () =>
launchImageLibrary(
{
mediaType: "photo",includeBase64: false,maxHeight: 200,maxWidth: 200,},async (response) => {
let reference = storage().ref("PicturesUsers/avatar.png");
let image = response;
const pathToFile =
`${utils.FilePath.PICTURES_DIRECTORY}/` + response.uri;
await reference.putString(pathToFile);
await reference.putFile(pathToFile);
console.log(pathToFile);
},async (response) => {
firestore()
.collection("Users")
.doc(await AsyncStorage.getItem("userID"))
.update({
Picture: response,})
.then(async () => {
setResponse(response);
console.log(pathToFile);
firestore()
.collection("Users")
.doc(await AsyncStorage.getItem("userID"))
.get()
.then((documentSnapshot) => {
console.log("User exists: ",documentSnapshot.exists);
if (documentSnapshot.exists) {
console.log(
"User data: ",documentSnapshot.data().Picture.uri
);
}
});
});
}
)
}
/>
</View>
</SafeAreaView>
);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)