Reputation: 312
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
Upvotes: 6
Views: 4730
Reputation: 3868
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';
Upvotes: 15