I have a problem on cordova (android), when I try to download a file (a .zip exactly), It always occured a error code 1. The url downloads well on my computer. Here is the code :
let fileTransfer = new FileTransfer(); url = encodeURI(url); fileTransfer.download( url, cordova.file.externalApplicationStorageDirectory, function(entry) { console.log('download complete: ' + entry.toURL()); }, function(error) { console.log('download error source ' + error.source); console.log('download error target ' + error.target); console.log('upload error code is ' + error.code); });
Thanks
Advertisement
Answer
The error was that I forgot to specify the name of the file when it will be downloaded on the device, I didn’t know I had to specify that. So here is the corrected code (modifications at lign 6) :
let fileTransfer = new FileTransfer(); url = encodeURI(url); fileTransfer.download( url, cordova.file.externalApplicationStorageDirectory+'whatever.png', function(entry) { console.log('download complete: ' + entry.toURL()); }, function(error) { console.log('download error source ' + error.source); console.log('download error target ' + error.target); console.log('upload error code is ' + error.code); });