I’m trying to delete an image from Firebase storage in React Native by downloadURL. Also i’m using web V9.
Writing down most essential chuncks of code:
import {
deleteObject,
getStorage,
ref
} from "firebase/storage";
...
// DownloadURL
const photo = "https://firebasestorage.googleapis.com.... ";
const storage = getStorage();
...
const storageRef = ref(storage, photo);
deleteObject(storageRef)
.then(() => {
console.log("File deleted successfully");
})
.catch((error) => {
console.log(error.message);
});
My code is inspired from here and I got this error:
[Unhandled promise rejection: FirebaseError: Firebase Storage: The
operation ‘deleteObject’ cannot be performed on a root reference,
create a non-root reference using child, such as .child(‘file.png’).
(storage/invalid-root-operation)]
I’m little confused.