I used writeFile(path, file, data, replace) method in $cordovaFile to write new file(pdf, jpg, text ). as a data I got data stream from restful service ..(it looks like %PDF-1.5↵%����↵1 0 obj↵..) The problem is I can write a file but it opens as a blank pdf but file size is correct. for data field I used data stream itself, blob object(var blob = new Blob([data], { type: 'application/pdf' });) ,
This is my code
var path = cordova.file.externalRootDirectory;
$cordovaFile.writeFile(path, "myCreatedPdf.pdf", blob, true)
.then(function(success){
console.log("file");
$cordovaFileOpener2.open(
success.target.localURL,'application/pdf'
);
}, function (error) {
console.log("error");
});
Please help me out.... any ideas...?