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

181
Vistas
How to add user image details like date or time to file name while uploading photos to firebase storage?

I am facing a problem related to uploading images in firebase storage. I am able to upload user images in firebase storage but it is only showing the newest image. it is not showing previous images. I think it is because of the path that I have created and the timestamp in this line of code:

 const path = 'photos/${Date.now()}.jpg';

I am using expo and React. Here is the code for uploading images:

uploadPhotoAsync = async uri => {
const path = 'photos/${Date.now()}.jpg';

return new Promise (async(res, rej) => {
    const response = await fetch(uri)
    const file = await response.blob()
    let upload = firebase.storage().ref(path).put(file)
    upload.on("state_changed", snapshot=>{

    }, err => {
        rej(err)
    }, async ()=>{
        const url = await upload.snapshot.ref.getDownloadURL()
        res(url)
    })
})
} 

Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There are several errors in your code:

Template literals should be delimited with backticks (`), while you delimit yours with standard single quotes ('): const path = 'photos/$(Date.now()}.jpg';.

Result: The value of path is always the same.

In addition, after the $ you use a parenthesis instead of a curly bracket.

Doing as follows shall do the trick:

const path = `photos/${Date.now()}.jpg`
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