Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda