hi i'm getting an error. while tryign to upload a post on firestore . the image is saved in firebase storage. but the firestore says image not found. when i removed the download url in my save post function . the post was saved on fire store along eith image url.
[Unhandled promise rejection: FirebaseError: Firebase Storage: Object 'post/Mfd7rHIi6sShBmcO5wHHfdDwlfE2/0.7bpr1c9ko5e' does not exist. (storage/object-not-found)]
code:
const childpath= `post/${firebase.auth().currentUser.uid}/${Math.random().toString(36)}`;
const submitPost = async () => {
const response= await fetch(image.uri); //hogya 1
const blob=await response.blob(); // 2
const rref=firebase.storage().ref().child(childpath).put(blob);
const taskCompleted = () => rref.snapshot.ref.getDownloadURL().then((snapshot) => {
savePostdata(snapshot);
console.log(snapshot)
})
const taskerror= snapshot => {
console.log(snapshot)}
rref.on("state_Changed", taskCompleted ,taskerror)
Alert.alert("Photo uploaded");
};
const savePostdata = (downloadURL) =>
{
firebase.firestore()
.collection('post')
.doc(firebase.auth().currentUser.uid)
.collection("userPosts")
.add({
downloadURL,
caption,
creation: firebase.firestore.FieldValue.serverTimestamp(),
})
}