Write a blob file in filesystem with Cordova - Ionic

Viewed 7717

I'm trying to save the pdf file of this example:

http://gonehybrid.com/how-to-create-and-display-a-pdf-file-in-your-ionic-app/

to my localData. I found i will need file plugin, but i don't know how to save the blob file to my system. I tried this two:

$cordovaFile.writeFile(cordova.file.externalCacheDirectory, "file.pdf", pdf, true)
.then(function(success) {
    console.log("file creato")
}, function(error) {
   console.log("errore creazione file")
});

or

$cordovaFile.createFile(cordova.file.dataDirectory, $scope.pdfUrl, true)
.then(function (success) {
    // success
}, function (error) {
    // error
});

but i can't storage it. How can i do that?

1 Answers
Related