Created
November 16, 2011 10:52
-
-
Save wei-lee/1369806 to your computer and use it in GitHub Desktop.
download file using $fh.file
This file contains 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 fileSrc = "http://example.com/test.pdf"; | |
var parts = fileSrc.split("/"); | |
var destFile = parts[parts.length - 1]; | |
var progressListener = function(progress){ | |
//progress value that is passed here is a float number between 0 and 1 | |
//convert it to percentage | |
$('#download_progress').html('<p> current progress: ' + progress*100 + '%' + '</p>'); | |
} | |
$fh.file( | |
{act:'download', src: fileSrc, dest: destFile, progressListener:progressListener}, | |
function(path){ | |
//open the downloaded file using $fh.webview | |
//$fh.webview can open most of the file formats on ios (pdf, doc, xls etc) | |
$fh.webview({act:'open', url: path}); | |
}, | |
function(err){ | |
alert(err); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment