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

274
Views
Can't find variable: getDownloadURL in react native firebase

I have copied and pasted code from the firebase documentation itself, still I am getting this error:

WARN Possible Unhandled Promise Rejection (id: 0): ReferenceError: Can't find variable: getDownloadURL

import storage from "@react-native-firebase/storage";

const pickImageAndUpload = async () => { try {

    launchImageLibrary({
        quality: 0.5
    }, (fileobj) => {
        console.log(fileobj.assets[0].uri);

        const uploadTask = storage().ref().child(`/userprofile/${Date.now()}`).putFile(String(fileobj.assets[0].uri))

        uploadTask.on('state_changed',
            (snapshot) => {
                const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
                if (progress == 100) alert('image uploaded')
            },
            (error) => {
                // Handle unsuccessful uploads
                alert('error uploading image')
            },
            () => {
                getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
                    setImage(downloadURL)
                });
            }
        );
    })

} catch (err) {
    alert(err)
    console.log(err);
}

}

I don't know why this error is coming, I have searched everywhere, this error does not occur in any other person code, please help me

You can check the official documentation here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you are using React Native Firebase then getDownloadURL() is a method on StorageReference and not a function (like in Modular SDK). Try refactoring the code as shown below:

const storageRef = storage().ref().child(`/userprofile/${Date.now()}`)

const uploadTask = storageRef.putFile(String(fileobj.assets[0].uri))

uploadTask.on('state_changed', (snapshot) => {
  const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
  if (progress == 100) alert('image uploaded')
}, (error) => {
  // Handle unsuccessful uploads
  alert('error uploading image')
}, () => {
  storageRef.getDownloadURL().then((downloadURL) => {
    setImage(downloadURL)
  });
});
about 4 years ago · Juan Pablo Isaza Report
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!