$cordovaFile.checkFile not finding file


#1

I have installed the file and file-transfer plugins. I am downloading an image to the local file system but having issues. The $cordovaFile.downloadFile is returning a result. I can log the result.toURL() and see the file path.I then try to confirm this with a call to $cordovaFile.checkFile passing the result.toURL(). I get a error returned of undefined. The reason I am checking its existence is I am having difficulty attaching a image using the email-composer plugin. It gives me an Attachment path not found: error.Am I missing something?

  var source = vm.catalogs[currentPage].largeimageuri;
        var filename = source.substring(source.lastIndexOf('/')+1);
        var dir = cordova.file.documentsDirectory;
        var filePath = dir + filename;   

$cordovaFile.downloadFile(source, filePath, true).then(function(result) {
            console.log("download complete: " + result.toURL());
            $cordovaFile.checkFile(result.toURL()).then(function(result) {
                // Success!
                console.log('File Success!');
            }, function(err) {                 
                // An error occured. Show a message to the user
                console.log(err);
            });
        }, function(err) {
            console.log(err);
        });


#2

The $cordovaFile.checkFile is working. I tested it with “filesystem.root.getFile(“readme.txt”, {create: true, exclusive: false},”. That was successful. The path I am passing has a ‘file://’ prefix added to the path. Would this affect the getFile method?


#3

Removing the ‘file://’ prefix and for the emulators benefit replaced %20 with empty space fixed my problem.