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

109
Visualizações
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
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