【发布时间】:2016-10-30 06:45:38
【问题描述】:
您好,我正在使用 Phonegap 创建 iOS 应用程序。我正在使用 Filetransfer API 下载图像文件。我正在使用以下代码下载文件
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";
}
我该如何解决这个问题?
【问题讨论】:
标签: ios cordova download phonegap-plugins file-transfer