ngCordova $cordovaFile save file to Camera Roll


#1

Is there any way to download a file from the internet (png) and save it to the camera roll? I was looking at $cordovaFile and it looks like what I need:

// parameters: source, filePath, trust all hosts (boolean), options
  $cordovaFile
    .downloadFile(source, filePath, true, options)
    .then(function(result) {
      // Success! 
    }, function(err) {
      // Error
    }, function (progress) {
      // constant progress updates
    });

but how do I actually get my filePath?


#2

The easiest way is to use a Cordova file path ‘cdvfile://localhost/…’. I found these release notes particularly helpful:
http://cordova.apache.org/news/2014/02/10/plugins-release.html

For the file system types, I just dug into the plugin sources. There’s a helpful table here too:
https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md