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

108
Views
Firebase Uploading Data to realtime database Everything does not show up

I am trying to upload a IMG files from my computer to my Firebase Realtime Database I have the image location stored inside of a json array and it includes the other details of the data I want to upload im wondering how I can upload the img to firebase and get the download url . I currently have something working only problem is that the images upload but only 1 or 2 objects will show up in real time database other than the expected number of 9

function makeCustomersHappy(){
    var count = 0;
    fetch("./upcominTasks.json")
    .then(response => {
        return response.json();
    })
    .then(jsondata =>{
        jsondata.forEach(position => {
            alert(count)
            count+=1;

            var imageName = JSON.stringify(position.name).replaceAll('"','')//neccesary for storing data
            var urlLink = JSON.stringify(position.url).replaceAll('"','')
            var itemName = JSON.stringify(position.name).replaceAll('"','')
            var store = JSON.stringify(position.store).replaceAll('"','')

            //get item name 
            document.getElementById('sometext').textContent = imageName;
            document.getElementById('upIMG').src  =  `./dropImages/${imageName}.jpg` //change image 
            //names the image for storage ref
            const storageRef = sRef(storage, `upcomingTasks/${imageName}.jpg`);

            var imgAddress = fetch(`http://127.0.0.1:5500/puppetBots/dropImages/${imageName}.jpg`)
            .then(function(response) {
                return response.blob()
            }).then(function(img_blob) {
                //location.reload()
                //uploads the image to firebase
                uploadBytes(storageRef,img_blob ).then((snapshot) => {
                    //the image that we just uploaded we get the  dowload url....                        
                    getDownloadURL(sRef(storage, `upcomingTasks/${imageName}.jpg`))
                    .then((img_url) => {
                          writeUserData(count,itemName,urlLink,img_url,store)                
                    });
                });
            });
        });              
    });    
}

async function writeUserData(id, name, url, imgLink,store) {
    const db = getDatabase();
    //id is basically the loop we are currently at
    set(gRef(db, 'UpcomingDropLinks/' +id), {
        ImageUrl: imgLink,
        ItemName: name,
        ItemUrl : url,
        Store:store
    });
}
makeCustomersHappy()
about 4 years ago · Juan Pablo Isaza
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!