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

189
Views
How to properly upload image to Firebase Storage and save link to firestore

Looked at this link How to upload image to firebase storage and save reference in the database in single transaction?, the recommended ones below it, softauthor and a few other sites to find out what I'm doing wrong but none worked. I'm trying to post the image to Storage then update the link in RTDB and Firestore. Here's the snippet, what am I doing wrong? (403 error) + Object { code_: "storage/object-not-found"

updatePfp.addEventListener("change", (e) => {
  file = e.target.files[0];
  var storageRef = firebase.storage().ref("users").child(user.uid);
  storageRef.put(file)
  firebase.storage().ref("users").child(user.uid).getDownloadURL()
    .then(imgUrl => {
      var downloadURL = imgUrl;
      db.collection("userInfo")
        .doc(user.uid)
        .update({
          downloadURL: downloadURL,
        })
        .then(function() {
          alert("saved");
        })
        .catch(function(error) {
          alert(error);
        });
    });
});

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to wait until the file has been completely uploaded before you can request its download URL.

storageRef.put(file).then(() => {
  firebase.storage().ref("users").child(user.uid).getDownloadURL()
    .then((downloadURL) => {
      ...
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!