How can i store pdf files into wp8.1 using ionic and cordova file plugin

  • Thread starter Thread starter WPCentral Question
  • Start date Start date
W

WPCentral Question

Hi

I do create an hybrid app using ionic framework and cordova file and file-transfer plugin.

I point to Downloads directory . Into Android it work?s fine. Into wp8 it does not download the pdf .

i try downloading a pdf via native browser just to test it and it works it drop the file into download directory

i just call it : pdfService.downloadPdf(url, fileName);

The pdf file does not reach the downloads diretory

i do refer as : fs.root.getDirectory("Downloads",{
create: true
},
How can i make cordova fiel an file-transfer handle the download of pdf files into windows phone 8.1 ?

My code is here:

.service('pdfService', ['$ionicLoading', function($ionicLoading) {

var lastUrl;
var lastFileName

return {
setParams: function(url, fileName) {
lastUrl = url;
lastFileName = fileName;
},
getParams: function() {
return {
url: lastUrl,
fileName: lastFileName
};
},
downloadPdf: function(url, fileName) {
lastUrl = url;
lastFileName = fileName;
//var deferred = $q.defer();
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
fs.root.getDirectory("Downloads",{
create: true
},
function(dirEntry) {
dirEntry.getFile(lastFileName,
{
create: true,
exclusive: false
},
function gotFileEntry(fe) {
//console.log('gotFileEntry 1'+fe.toURL());
var p = fe.toURL();
//console.log("filepath "+p);
fe.remove();
ft = new FileTransfer();
$ionicLoading.show({
template: 'Downloading'
});
ft.download(
encodeURI(lastUrl),
p,
function(entry) { //alert('entry 1 '+entry.toURL()); //d.resolve(entry); //return d.promise;
window.open(entry.toURL(), '_system', 'location=yes,toolbar=yes,closebuttoncaption=Close PDF,enableViewportScale=yes,fullscreen=no');
$ionicLoading.hide();
},
function(error) {
alert('Error');
alert("Download Error Source -> " + error.source);
},
false,
null
);
},
function() {
alert("Get file failed");
}
);
}
);
},
function() {
alert("Get file failed"+fe.toURL());
console.log("Request for filesystem failed");
});
},
load: function(fileName) {
lastFileName = fileName; //alert("Entrou no metodo load: "+lastFileName);

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
fs.root.getDirectory(
"Downloads",
{
create: false
},
function(dirEntry) {
dirEntry.getFile(
lastFileName,
{
create: false,
exclusive: false
},
function gotFileEntry(fe) {
//alert('Metodo load gotFileEntry '+fe.toURL());//alert(' fe.toURL() '+fe.toURL()); //$scope.imgFile = fe.toURL();//alert(' scope.imgFile '+$scope.imgFile);
window.open(fe.toURL(), '_system', 'location=no,toolbar=yes,closebuttoncaption=Close,enableViewportScale=yes');
},
function(error) {
$ionicLoading.hide();
alert("Error getting file");
}
);
}
);
},
function() { //alert("Error requesting filesystem 1 ");
$ionicLoading.hide();
alert("Error requesting filesystem 2 ");
});
} //scope load
// }),
} //return
}])

Thank?s in advance
 
Is there anybody who already sucessfuly implements cordova file-tansfer into windows phone 8.1?

I am using Lumia 635, cordova-file and cordova file-transfer.
 
Just give up from using cordova file plugin to download and/or load pdf files and opening into the browser if someone could use cordova file into windows phone please let me know how to do it.
 

Members online

Forum statistics

Threads
332,616
Messages
2,255,564
Members
428,716
Latest member
csam79246