Last active
August 29, 2015 14:13
-
-
Save greenlikeorange/89f49b449437476fb107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileTransfer, uri; | |
function downloader(filesURLs, cloneArray){ | |
if(cloneArray){ | |
// Do not manipulate old memory | |
cloneArray = Array.prototype.concat.call([], filesURLs); | |
} | |
if(cloneArray.length === 0){ | |
// End on done loop | |
return false; | |
} | |
fileTransfer= new FileTransfer(); | |
uri = encodeURI(cloneArray.shift()); | |
fileTransfer.download( | |
uri, | |
fileURL, | |
function(entry) { | |
console.log("download complete: " + entry.toURL()); | |
// Download next URL | |
downloader(filesURLs, cloneArray); | |
}, | |
function(error) { | |
console.log("download error source " + error.source); | |
console.log("download error target " + error.target); | |
console.log("upload error code" + error.code); | |
// Download next URL | |
downloader(filesURLs, cloneArray); | |
}, | |
false, | |
{} | |
); | |
} | |
/** | |
* fulesURLs = ["http://some.server.com/download-1", "http://some.server.com/download-2"]; | |
* | |
* downloader(fileURLs); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment