ionic File download using FTP

705 Views Asked by At

I have a problem with the FTP plugin (http://ionicframework.com/docs/native/ftp/). I want to download a series of files from an FTP one by one and once a file is downloaded the application should read the file and insert the data into a database. The problem is that the application reads the file before it is downloaded 100% and I do not know how to fix it.

According to the documentation, the download percentage is returned, but I do not know how to launch the function once it reaches 100% (resDL=1).

This is my code:

this.ftp.download(pathLocal+'lecturaData/'+filename, filename)
            .then((resDL: any)=>{
                if (resDL == 1) {
                    return this.FromFileToBBDD(this.file.externalDataDirectory+'lecturaData/', filename);
                }
            })
          .catch((error: any) => {
            console.error(error);
          });

Thank you very much.

0

There are 0 best solutions below