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
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With