Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic native File plugin's getFile() method

I'm using native file plugin on Ionic 3 app.Can you please tell me how to use getFile() method on it? I can't find a proper implementation of that method.Its signature is like below.But I don't know how to give the directoryEntry parameter.

getFile(directoryEntry, fileName, flags)
like image 472
Sampath Avatar asked Dec 08 '25 10:12

Sampath


1 Answers

constructor(private file: File, private platform: Platform) {

    platform.ready()
      .then(() => {
        return this.file.resolveDirectoryUrl(this.file.dataDirectory)
      })
      .then((rootDir) => {
        return this.file.getFile(rootDir, 'main.jpeg', { create: false })
      })
      .then((fileEntry) => {
        fileEntry.file(file => {
          console.log(file)
        })
      })
}
like image 156
Thomas Avatar answered Dec 11 '25 15:12

Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!