Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
Firebase storage delete image by downloadURL V9

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.

Later edit:

My function which upload the image and get the download url:

    // uri is returned from "expo-image-picker"
    const uploadImageAsync = async (uri) => {
        // manipulateAsync imported from 'expo-image-manipulator'
        const manipResult = await manipulateAsync(uri, [], {
          compress: 0.6,
          format: "jpeg",
        });
        const response = await fetch(manipResult.uri);
        const blob = await response.blob();
        
            const imageName = Date.now().toString();
            const fileRef = ref(storage, `avatar/${user.uid}/${imageName}.jpg`);
            const result = await uploadBytes(fileRef, blob);
        
            getDownloadURL(fileRef).then((snapshot) => {
              // downloadURL is added to Redux state to be used later
              dispatch(addPhoto(snapshot));
            });
          };
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!