Skip to content

Instantly share code, notes, and snippets.

@devgeeks
Last active January 17, 2023 15:17

Revisions

  1. devgeeks revised this gist Feb 19, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions example-download-and-open.js
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,12 @@ function gotFile(fileEntry) {
    uri,
    fileEntry.fullPath,
    function(entry) {
    //window.plugins.webintent.startActivity({
    // action: WebIntent.ACTION_VIEW,
    // url: encodeURI(entry.fullPath),
    //}, function () {}, function (error) {
    // console.log(error);
    //});
    window.open(encodeURI(entry.fullPath),"_blank","location=no,enableViewportScale=yes")
    console.log("download complete: " + entry.fullPath);
    },
  2. devgeeks revised this gist Feb 19, 2013. 1 changed file with 15 additions and 15 deletions.
    30 changes: 15 additions & 15 deletions example-download-and-open.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fail);

    function fail(error) {
    console.log(error)
    console.log(error)
    }

    function gotFS(fileSystem) {
    @@ -15,19 +15,19 @@ function gotDir(dirEntry) {
    function gotFile(fileEntry) {
    // Start FileTransfer here...
    var fileTransfer = new FileTransfer();
    var uri = encodeURI("http://cb.vu/unixtoolbox.pdf");
    var uri = encodeURI("http://cb.vu/unixtoolbox.pdf");

    fileTransfer.download(
    uri,
    fileEntry.fullPath,
    function(entry) {
    window.open(encodeURI(entry.fullPath),"_blank","location=no,enableViewportScale=yes")
    console.log("download complete: " + entry.fullPath);
    },
    function(error) {
    console.log("download error source " + error.source);
    console.log("download error target " + error.target);
    console.log("upload error code" + error.code);
    }
    );
    fileTransfer.download(
    uri,
    fileEntry.fullPath,
    function(entry) {
    window.open(encodeURI(entry.fullPath),"_blank","location=no,enableViewportScale=yes")
    console.log("download complete: " + entry.fullPath);
    },
    function(error) {
    console.log("download error source " + error.source);
    console.log("download error target " + error.target);
    console.log("upload error code" + error.code);
    }
    );
    }
  3. devgeeks created this gist Feb 19, 2013.
    33 changes: 33 additions & 0 deletions example-download-and-open.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fail);

    function fail(error) {
    console.log(error)
    }

    function gotFS(fileSystem) {
    fileSystem.root.getDirectory("data", {create: true, exclusive: false}, gotDir, fail);
    }

    function gotDir(dirEntry) {
    dirEntry.getFile("unixtoolbox.pdf", {create: true, exclusive: false}, gotFile, fail);
    }

    function gotFile(fileEntry) {
    // Start FileTransfer here...
    var fileTransfer = new FileTransfer();
    var uri = encodeURI("http://cb.vu/unixtoolbox.pdf");

    fileTransfer.download(
    uri,
    fileEntry.fullPath,
    function(entry) {
    window.open(encodeURI(entry.fullPath),"_blank","location=no,enableViewportScale=yes")
    console.log("download complete: " + entry.fullPath);
    },
    function(error) {
    console.log("download error source " + error.source);
    console.log("download error target " + error.target);
    console.log("upload error code" + error.code);
    }
    );
    }