user3311146
user3311146

Reputation: 3

Phonegap 3.3.0 iOS FileSystem plugin not firing complete, progress or error

I am trying to use the FileTransfer plugin on iOS with Phonegap 3.3.0. It has been working in my app in the past, but since I updated all my libraries JQuery (1.11.0), JQuery Mobile(1.4.1) I am not getting any callbacks associated with the file transfers.

I know the files are downloading, because I can see them appear on the filesystem in the iOS Simulator temporary files, etc. Furthermore, they seem to have completed downloading as the files appear complete.

My code:

function download(url, dest, cb) {

    var fileTransfer = new FileTransfer();
    console.log("remote:"+url+" local:"+dest);

    fileTransfer.onprogress = progress;
    fileTransfer.download(url, dest, downloadSuccess, fail);
}
function progress() {
    console.log("progress:"+arguments);
}
function fail() {
    console.log("fail:"+arguments);
}
function downloadSuccess() {
    console.log("download complete: " + arguments);
}

Any thoughts about what I might be doing wrong?

Upvotes: 0

Views: 633

Answers (2)

eshcol
eshcol

Reputation: 569

Phonegap 3.3.0's Filesystem has a new approach. If you have been using fullpath for entry, you need to replace that with toURL().

Also in your config.xml file you got to add

<preference name="iosPersistentFileLocation" value="Compatibility" />

Your best bet would be to go over this link https://github.com/apache/cordova-plugin-file/blob/dev/doc/index.md

Making these changes worked for me. Hope it works for you too.

Upvotes: 1

QuickFix
QuickFix

Reputation: 11721

I think your callbacks are fired but you have syntax errors because you try to use arguments parameter but do not define it.

Also, as the callbacks take objects, using arguments in the console.log, it will only display 'object'. You should either stringify it or use a property of the object.

for example:

function download(url, dest, cb) {

    var fileTransfer = new FileTransfer();
    console.log("remote:"+url+" local:"+dest);

    fileTransfer.onprogress = progress;
    fileTransfer.download(url, dest, downloadSuccess, fail);
}
function progress(arguments) {
    console.log("progress:"+Math.floor(100*arguments.loaded/arguments.total)+"%");
}
function fail(arguments) {
    console.log("fail error code:"+arguments.code);
}
function downloadSuccess(arguments) {
    console.log("download complete: " + arguments.bytesSent + " bytes sent");
}

Upvotes: 1

Related Questions