How to retrieve the file from MySQL Database using Ionic app and download it

Hi , is there anyone know on how can i retrieve the file from mysql database and download it , via PDF File or any kind of file… i can’t get any source from youtube and google . Help me about my problem guys…

Hi zeukegreen, I’m trying to do the same thing, did you find a solution?

This works for me in my Ionic V3 app on Android (not tested on iOS), where _File is from:

import { File, DirectoryEntry } from '@ionic-native/file';

constructor(
  public _File: File) {
}
    var fileUrl = this._File.applicationStorageDirectory + "databases/<your-db-name-here>";             
    var outFileName = "backup.db";
    this._File.resolveLocalFilesystemUrl(fileUrl).then(fileEntry => {
      this._File.resolveDirectoryUrl(this._File.externalDataDirectory || this._File.documentsDirectory).then(dirEntry => {
        fileEntry.copyTo(dirEntry, outFileName, 
          (success) => {                    
            // Now I use my backup file and upload to dropbox...             
          },
          (err) => {
            console.log(JSON.stringify(err));
          }
        );
      }).catch(err => {
        console.log(JSON.stringify(err));
      });
    });

Hi Daveshirman,
I’m not sure what this code does, but maybe if I give more Info you can explain it to me, and tell me if I can use it for my case?
I created a RESTful API that takes data from mysql database and the data that comes back in the page is:

Array (1)
File:
data: (25474) [37, 80, 68, 70, 45, 49, 46, 55, 10, 10, 52, 32, 48, 32, 111, 98, 106, 10, 40, 73, 100, 101 , 110, 116, 105, 116, 121, 41, 10, 101, 110, 100, 111, 98, 106, 10, 53, 32, 48, 32, 111, 98, 106, 10, 40, 65, 100 , 111, 98, 101, 41, 10, 101, 110, 100, 111, 98, 106, 10, 56, 32, 48, 32, 111, 98, 106, 10, 60, 60, 10, 47, 70 , 105, 108, 116, 101, 114, 32, 47, 70, 108, 97, 116, 101, 68, 101, 99, 111, 100, 101, 10, 47, 76, 101, 110, 103, 116 , 104, 32, 50,…]
type: “Buffer”
I want to be able to convert the file in pdf and show it on the page, if not show then download. Thanks a lot for your time!

Your question was phrased as if you wanted to get the local database file from an installed Ionic app and then do something with it.

That’s what my code does.