Reputation: 419
The onprogress
event handler never seems to be called. The success callback comes through fine and the download works. Is there something I'm doing wrong here?
filesystem.root.getFile('/path/to/file', { create: true }, function (file) {
var transfer = new FileTransfer();
transfer.onprogress = function () {
console.log(arguments);
};
transfer.download(
'http://example.com/path/to/file',
file.toURL(),
function () { console.log('success'); },
function () { console.log('error'); },
true
);
}, function () { console.log('error'); });
The app uses PhoneGap 3.5.0 with the newest file and file-transfer plugins. I'm testing on an iPad with iOS 8.
Upvotes: 1
Views: 2044
Reputation: 165
You seem to be missing the arguments variable on the onprogress function definition.
It should be:
transfer.onprogress = function (progressEvent) {
console.log(progressEvent);
console.log(progressEvent.loaded); //Loaded bytes
console.log(progressEvent.total); //Total bytes
console.log(progressEvent.lengthComputable); //TRUE if the destination server informs total file length
};
You can find the docs here: http://docs.phonegap.com/en/edge/cordova_file_file.md.html#FileTransfer
Hope it helps!
Upvotes: 1