Hello!
I am trying to download file with cordova-plugin-file-transfer on Android device and emulator:
public async downloadFile(task: DownloadTaskModel) {
let path = null;
if (this.platform.is('ios')) {
path = this.file.documentsDirectory;
} else {
path = this.file.dataDirectory;
console.log('downloadFile():', path);
}
const fileTransfer = this.transfer.create();
fileTransfer.download(
task.download_url,
path + task.publish_file,
true, {
headers: {
'Connection': 'close'
}
})
.then(entry => {
console.log('downloadFile(): File downloaded: ', entry);
})
.catch(error => {
console.error('downloadFile(): Dowload failed:', error);
});
}
But nothing is happenning. fileTransfer.download(…) got response from server but downloading does not start:
Should fullPath be “/BigBuckBunny_320x180.mp4” or something longer? Please, tell me what is wrong in response data?
“cordova-plugin-file”: “6.0.1”,
“cordova-plugin-file-transfer”: “1.7.1”,
Ionic:
Ionic CLI : 5.2.0 (/home/artem/.nvm/versions/node/v10.14.1/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.5.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Capacitor:
Capacitor CLI : not installed
@capacitor/core : not installed
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0, browser 6.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 13 other plugins)
Utility:
cordova-res : 0.3.0 (update available: 0.5.1)
native-run : 0.2.2 (update available: 0.2.7)
System:
Android SDK Tools : 26.1.1 (/home/artem/SDK/Android)
NodeJS : v10.14.1 (/home/artem/.nvm/versions/node/v10.14.1/bin/node)
npm : 6.9.2
OS : Linux 4.9