I've ran into some problems while using cordova plugin File Transfer. Thats my code:
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {create: true, exclusive: false},
function gotFileEntry(fileEntry) {
var sPath = fileEntry.fullPath.replace("dummy.html", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download( 'http://cordova.apache.org/images/cordova_bot.png', sPath + photo.original_name,
function (theFile) {
alert('success: ' + JSON.stringify(theFile));
console.log("download complete: " + theFile.toURI());
// showLink(theFile.toURI());
},
function (error) {
alert('error: ' + JSON.stringify(error));
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code: " + error.code);
},
true
);
})
},
function (error) {
alert('error request: ' + JSON.stringify(error));
}
);
The fileTransfer.download's error callback is being returned with error code 3, http 401. I already updated the File and FileTransfer plugins, my cordova version is 4.3.0. Also checked my config.xml for
<access origin="*" />
but it's there. I tried adding the header Connection: close, but no result. Tried setting the download's 4th param to its default (false) too - no luck.
Testing on Android tablet.
Anyone anything? Thanks!
Just found a "solution" to my problem. What I did was to downgrade the file-transfer plugin version from 0.5.0 to 0.4.8.
If someone ever face similar problem, do as below:
That's it. Seems to be working well, at least the success callback is returned, didn't really test more of it.