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

182
Views
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 answers
Answer question

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 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!