Answer the question
In order to leave comments, you need to log in
Error loading shaft from android app?
Good evening. There was a problem while developing a mobile app using Apache Cordova tools.
I need to implement the download of files (mostly pdf) that come in the server's response.
Apache Cordova has a plugin for this . I install it and use the script that the developers give in the example, it turns out like this:
$(document).on('click', 'a[download]', function (e) {
e.preventDefault();
uri = $(this).attr('href');
downloadFile(uri);
})
function downloadFile(uri) {
var fileTransfer = new FileTransfer();
var uri = encodeURI(''+uri+'');
var fileURL = "/Download";
fileTransfer.download(
uri, fileURL, function(entry) {
alert("download complete: " + entry.toURL());
},
function(error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("download error code" + error.code);
},
false, {
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question