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

198
Visualizações
How to save pdf file from Firebase in local folder from web

How do I download and save a pdf file from Firebase storage. During upload I save upload infomation on real time firebase node like this: enter image description here

while my storage is as follow: enter image description here

My save btn is linked to this function:

function savepdfFile(){
 let selectedGroup = document.getElementById("groupname");
 let selectedDate = document.getElementById("dateId");
 let selectedGroupValue = selectedGroup.value;
 let selectedDateValue = selectedDate.value;
 let mdate = "";
 mdate = changeDateForamat(selectedDateValue);
 downloadPDFDoc(selectedGroupValue,mdate);
}

I retrieve information of this pdf file from firebase real time node as follow when a save button is clicked;

function downloadPDFDoc(groupname,mdate){
let pdfName, pdfUrl;
firebase.database().ref('SessionPDFStorage').once('value',function(snapshot){
    snapshot.forEach(
        function(ChildSnapshot){                
            //let mLocation = ChildSnapshot.val().province;
            let mGroup = ChildSnapshot.val().selectedGroup;
            let mydate = ChildSnapshot.val().currentDate;

            let ddate = changeDateForamat(mydate);

            if(groupname == mGroup && mdate == ddate){                    
                pdfName =  ChildSnapshot.val().fileName;
                pdfUrl =  ChildSnapshot.val().fileImageUri;
            }               
        }
    );
    loadScannedImage(pdfName,pdfUrl);        
 });    
}

How do I develop the loadScannedImage(pdfName,pdfUrl) funtion below to using the above information to save the file on the local folder dynamically? example automatically save this pdf to a local c:\download directory.

function loadScannedImage(pdfName,pdfUrl){

}

I have seen some implementation of FileSaver.js and Blob.js but it is not quite clear how I would use them.

Any help will be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I created an anchor element and pass both pdf name and its url link as as attributes follow inside loadscnnedImage:

function loadScannedImage(pdfName,ImgUrl){   
 var element = document.createElement('a');
               element.setAttribute('href',`${ImgUrl}`);
               element.setAttribute('download', pdfName);
               document.body.appendChild(element);
               element.click()
}

but I would have liked to dynamically safe the pdf file directly to browsers default downloaded folder on the machine. But this works too

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