Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda