Código:
var FileTransfer = function() {}; FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) { // sanity parameter checking if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum."); var win = function(result) { var entry = null; if (result.isDirectory) { entry = new (require('cordova/plugin/DirectoryEntry'))(); } else if (result.isFile) { entry = new (require('cordova/plugin/FileEntry'))(); } entry.isDirectory = result.isDirectory; entry.isFile = result.isFile; entry.name = result.name; entry.fullPath = result.fullPath; successCallback(entry); }; var fail = function(e) { var error = new FileTransferError(e.code, e.source, e.target, e.http_status); errorCallback(error); }; exec(win, errorCallback, 'FileTransfer', 'download', [source, target]); }; module.exports = FileTransfer; });