Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fileDownload(dirName, fileURL, fileName) {
- window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, fsAccess, fsFail);
- function fsAccess(fileSystem) {
- fileSystem.root.getDirectory(dirName, { create: true, exclusive: false }, dirReady, dirFail);
- }
- function fsFail() {
- console.log("Filesystem Access Failed");
- }
- function dirFail() {
- console.log("Directory Access Failed");
- }
- function dirReady(entry) {
- window.appRootDir = entry;
- console.log(JSON.stringify(window.appRootDir));
- var fileTransfer = new FileTransfer();
- fileTransfer.download(
- fileURL,
- window.appRootDir.nativeURL + fileName,
- function (theFile) {
- console.log("download complete: " + theFile.toURL());
- },
- function (error) {
- console.log(JSON.stringify(error));
- }
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement