ngCordova FileTransfer no progress events?


#1

This may well be something very simple but I can’t find it for the life of me. In my app I use ngcordova file and file transfer plugins. They are both present and working.

I have some code that when called will download a file to the local file system, this works fine and the file is downloaded without any issue and success called, or error called if I pull the network connection part way through.

The problem is I don’t receive any progress events at all and I can’t figure out why? I have followed the guide on the ngcordova example and various other examples but progress just never seems to get triggered at all.

A simple console.log in the progress block never even executes.

Here is a sample of my code where error and success work fine but progress is never entered:

		$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
			.then(function(result){
				//Success
				//inject the file location into the song object
				song.targetPath = targetPath;
				//updated the cachedSongs list with the new object
				o.updateCachedSongs(song);
				console.log("successfully downloaded: " + song.title);
			}, function(err){
				//Error
				console.log("download failed for " + song.title);
			}, function(progress){
				//Progress
				console.log("test1");
				$timeout(function () {
					console.log("test2");
      			downloadProgress = (progress.loaded / progress.total) * 100;
    			})
			});
	  }) 

Any pointer would be greatly appreciated as once the progress event is actually being called then I can add a progress indicator for downloads for the user.

I am working on ios 8.3, same behaviour on physical device or emulator.


#2

I put a simple console.log event into ngcordova filetransfer download code and it looks like ngcordova is never receiving any progress events from the file transfer plugin as it never logs:

    ft.onprogress = function (progress) {
      console.log("Q notify!!");
      q.notify(progress);
    };

#3

A bit more troubleshooting. I have just run the app on an android device to try and isolate the issue and on android the progress events are triggered as are all of my breakpoints so this seems to be iOS specific.


#4

Did you set the right TargetPath? It’s seem TargetPath got wrong : )


#5

I’ll provide an example and code for generating the target path but the file downloads and can then be read using the target path so it seems to work for both file and file transfer.