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

100
Vistas
Firebase function to return download URL

I'm trying to return some data using a firebase function for security reasons, within said data is a firebase storage file location. I want to replace the location with the download URL so the front end can display the image. Here is a mock-up of my code

// The Cloud Functions for Firebase SDK to create Cloud Functions and set
// up triggers.
const functions = require("firebase-functions");

// The Firebase Admin SDK to access Firestore.
const firebase = require("firebase-admin");

firebase.initializeApp();


exports.getDetails = functions.https.onRequest(async (request, response) => {
    
    //...loads data 

    let details = [];
    await dataArray.forEach(async (doc) => {

        let data = doc.data();

        if(doc.data().type=="Photo Select" || doc.data().type=="Document Select"){

             try{
            url =  await firebase
            .storage()
            .ref()
            .child(doc.data().value)
            .getDownloadURL();
            } catch(e){
                console.log(e)
            }

            data["value"]=url? url : "";

         

        }  
        details.push(data)
    
    })
    response.json({ 
            details: details
        })
})

but in the error logs on running I'm getting "TypeError: firebase.storage(...).ref is not a function"

Any help would be appreciated :D

about 4 years ago · Juan Pablo Isaza
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