Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic4/Angular7 - Property 'dataDirectory' does not exist on type 'File'

i user file transfer for download file that it's need File native also in ionic v3 i used it and hasn't any problem but now in ionic v4 when i use that, it's got Error : Property 'dataDirectory' does not exist on type 'File'

my code => download.page.ts

download() {
    const fileTransfer: FileTransferObject = this.transfer.create();
    this.plt.ready().then(() => {
      const url = 'http://www.test.com/file.mp3';
      fileTransfer.download(url, this.file.dataDirectory + 'file.mp3').then((entry) => {
        console.log('download complete: ' + entry.toURL());
      }, (error) => {
        // handle error
        console.log('download EROR: ' + error);
      });
    });
  }

File imported in download page and providers app module

like image 310
ebeliejinfren Avatar asked Feb 05 '19 09:02

ebeliejinfren


1 Answers

Ionic 4 uses different import paths in compairson to Ionic 3.

import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer/ngx';
import { File } from '@ionic-native/file/ngx';
like image 147
Tomas Vancoillie Avatar answered Nov 05 '22 07:11

Tomas Vancoillie