2015-07-21 21 views
0

我使用Phonegap和jQuery Mobile創建了一個應用程序,它在iPad mini中運行良好,並且我使用文件傳輸來下載文件設備,日誌說,文件下載成功,但我找不到在裝置內的任何PDF文檔,這是我的代碼:Phonegap使用File-Transfer在iOS下載文件並在設備中訪問它

function iosDownload() { 
    var fileTransfer = new FileTransfer(); 
    var uri = encodeURI("WEB_SERVICE_URL"); 

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) { 
     var fileNamePath = fs.root.fullPath + "/file.pdf"; 
     fileTransfer.download(uri, fileNamePath, function(entry) { 
      console.log("download complete: " + entry.fullPath); 
      alert("Reporte generado exitosamente"); 
      }, function(error) { 
       console.log("download error source " + error.source); 
       console.log("download error target " + error.target); 
       console.log("upload error code" + error.code); 
       alert("Error al generar reporte. Intentar mas tarde"); 
      }, false, { 
       headers: { 
        "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" 
       } 
      } 
     ); 
    }); 
} 

日誌中的反應顯示了這種路徑:

下載完成:/var/mobile/Containers/Data/Application/DEVICE_UNIQUEID/Documents/file.pdf

我找不到文檔,有什麼方法可以將它下載到Downloads文件夾中嗎?或者有什麼方法可以在該位置找到它?謝謝。

回答

1

一下這個文件的路徑

Users/YourAccount/Library/Developer/CoreSimulator/Devices/45BCFA0B-C37A-4A85-A63C-(device's ID)/data/Containers/Data/Application/E4472D7E-A833-4985-89CF-(App's ID)/Documents/yourfile.pdf 

希望有所幫助。 您保存的相同路徑。

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) { 
    var fileNamePath = fs.root.fullPath + "/file.pdf"; 
    $scope.fileToShow = fileNamePath; 

} 

HTML

<div>fileToShow</div> 

如果你想看到你的iPad上的PDF,安裝IEXPLORER

iExplorer

連接你的iPad和開放IEXPLORER。然後轉到文件和應用程序,然後選擇您的應用程序。您的pdf將在文檔下。

+0

謝謝,但這是模擬器,我可以在其中找到文件,但我現在正在mi iPad中運行應用程序,我無法找到它們。 – saman0suke

+0

我編輯答案。歡呼! – Phyo

相關問題