- This topic has 9 replies, 3 voices, and was last updated 12 years ago by
support-octavio.
-
AuthorPosts
-
John-DohertyMemberHow 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%3D9There 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);
}
);June 4, 2013 at 5:16 pm #339684
support-octavioMemberHi John,
I haven’t done that, but I noticed that the variable filePath probably hasn’t been declared/initialized causing a syntax error.
June 13, 2013 at 9:26 am #339918
John-DohertyMemberThanks 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!June 13, 2013 at 9:27 am #339919
John-DohertyMemberBy the way that is not my actual website
June 17, 2013 at 4:50 pm #340027
support-octavioMemberHi 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?
June 17, 2013 at 5:37 pm #340030
BrandonMemberJust 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.
June 22, 2013 at 3:44 pm #340224
John-DohertyMemberNone 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!
June 22, 2013 at 3:46 pm #340225
John-DohertyMemberNot even this works as well
window.open('http://schoolissuperfun.comuv.com/test.html', '_system');
to open in native browser
June 22, 2013 at 3:48 pm #340226
John-DohertyMemberI am using phonegap 2.7.0 and a android device by the way
July 12, 2013 at 1:23 pm #340762
support-octavioMemberHi 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
-
AuthorPosts