facebook

How can you download a file from skydrive within PhoneGap

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #339589 Reply

    John-Doherty
    Member

    How would I enable my Phonegap app to download files from skydrive all of my download links are like this
    https://skydrive.live.com/download.aspx?cid=631E917390CA9E25&resid=631E917390CA9E25%21403&canary=GaaNjS0DzKVQ2LJFK8DEKw4GG1Pcb7K7RD7N1fRQy38%3D9

    There is a button on the webpage called custom2 and that has those links. I would preferable would want to modify my java class instead of the index.html. Any help is appreciated. I have tried using a button when clicked it runs javascript but this is not working
    var fileTransfer = new FileTransfer();
    var uri = encodeURI(“https://skydrive.live.com/download.aspx?cid=631E917390CA9E25&resid=631E917390CA9E25%21392&canary=GaaNjS0DzKVQ2LJFK8DEKw4GG1Pcb7K7RD7N1fRQy38%3D9”);

    fileTransfer.download(
    uri,
    filePath,
    function(entry) {
    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);
    }
    );

    #339684

    Hi John,

    I haven’t done that, but I noticed that the variable filePath probably hasn’t been declared/initialized causing a syntax error.

    #339918

    John-Doherty
    Member

    Thanks for the help. But I am still stuck with the same problem how would I download a file within the native app and save it to the android downloads folder, I am now willing to move away from skydrive as I have all of my files on my own server. So who would it be done. I have already looked on stack overflow, phonegap api and google groups but none have helped me. By the way the file is mp4 and skydrive did not work because of the https encryption. The link to the server is like http://www.mywebpage.com/video.mp4
    Any help would be appreciated!

    #339919

    John-Doherty
    Member

    By the way that is not my actual website

    #340027

    Hi John-Doherty,

    Can you please show us what you are doing (code used f.e.) and describe what do you think may be the problem?

    #340030

    Brandon
    Member

    Just a guess as I havent tried this and this is off the top of my head but set your mp4 as the file path:

    var filePath = “http://www.mywebpage.com/video.mp4”;

    Then, if you change the console.log(…) to alert(…) it will popup an alert when that comes up and let you know more of whats going on.

    #340224

    John-Doherty
    Member

    None of the solutions fixed it this is my final code:

    <!DOCTYPE html>
    <html>
      <head>
        <title>Downloading...</title>
    
        <script type="text/javascript" charset="utf-8" src="phonegap-2.7.0.js"></script>
        <script src="phonegap.js"></script>
        <script type="text/javascript" charset="utf-8">
        
    
        // Wait for Cordova to load
        //
        document.addEventListener("deviceready", onDeviceReady, false);
    
        // Cordova is ready
        //
        function onDeviceReady() {
          var fileTransfer = new FileTransfer();
          var filePath = "file:///android_assets/www/";
          var uri = encodeURI("http://marions.net/Resources/English/English%20Movies/Movies%20Subtitles/ChapletofDivineMercysubtitles.mp4");
          fileTransfer.download(
        uri,
        filePath,
        function(entry) {
            alert("download complete: " + entry.fullPath);
        },
        function(error) {
            alert("download error source " + error.source);
            alert("download error target " + error.target);
            alert("upload error code" + error.code);
        },
        false,
        {
            headers: {
                "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
            }
        }
    );
    
                 
    
        }
    
        </script>
      </head>
      <body>
      </body>
    </html>

    it still does not work. Thanks for all the help so far!

    #340225

    John-Doherty
    Member

    Not even this works as well

    window.open('http://schoolissuperfun.comuv.com/test.html', '_system');
    

    to open in native browser

    #340226

    John-Doherty
    Member

    I am using phonegap 2.7.0 and a android device by the way

    #340762

    Hi John,

    I have tested and implemented next code example in a mobione app and worked well for me. It could help you as a example to get it working: https://gist.github.com/nathanpc/2464060#file-phonegap_download_example-html-L48

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: How can you download a file from skydrive within PhoneGap

You must be logged in to post in the forum log in