写文件系统中的BLOB文件,科尔多瓦 - 离子

问题描述:

我试图挽救这个例子中的PDF文件:写文件系统中的BLOB文件,科尔多瓦 - 离子

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

我localData。我发现我需要文件插件,但我不知道如何将Blob文件保存到我的系统。我想这二:

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

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

但我不能存储它。我怎样才能做到这一点?

我的解决办法:

 var pathFile = ""; 
     var fileName = "report.pdf"; 
     var contentFile = blob; 

     if (ionic.Platform.isIOS()) { 
      pathFile = cordova.file.documentsDirectory 
     } else { 
      pathFile = cordova.file.externalDataDirectory 
     } 

     $cordovaFile.writeFile(pathFile, fileName, contentFile, true) 
      .then(function(success) { 
       //success 
      }, function(error) { 

       alert("error in the report creation") 

      }); 
+0

我使用这种方法,由我找不到在iPhone上的文件。被保存的地方在哪里? – Tirias

+0

使用XCode查看设备上的应用程序文件夹 – Mirko