Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda