2
您好我正在使用Phonegap創建iOS應用程序。我正在使用Filetransfer API來下載圖像文件。我使用下面的代碼來下載文件在Phonegap iOS中下載文件時出錯
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, createFolder, null);
function createFolder(fileSystem) {
console.log('gotFS');
fileSystem.root.getDirectory("MyDirectory", {
create: true,
exclusive: false
}, MyDirectorySuccess, MyDirectoryfail);
}
function MyDirectorySuccess(entry) {
console.log('gotDirectorySuccess');
downloadFile(entry);
}
function downloadFile(entry)
{
console.log('downloadFile');
var filePath = entry.fullPath+'test.jpg';
var fileTransfer = new FileTransfer();
var url = 'https://www.facebookbrand.com/img/fb-art.jpg';
fileTransfer.download(
url, filePath, function(entry) {
console.log("success");
}, function(error) {
console.log("error");
}, true, {});
}
當我在iOS設備上運行它,我得到的錯誤:
FileTransferError {
body = "Could not create path to save downloaded file: You don\U2019t have permission to save the file \U201cMyRecipeDirectory\U201d in the folder \U201cMonarch13A452.J72OS\U201d.";
code = 1;
"http_status" = 200;
source = "https://www.facebookbrand.com/img/fb-art.jpg";
target = "cdvfile://localhost/root/MyDirectory/test.jpg";
}
我如何解決這個問題?