【发布时间】:2014-10-15 10:27:48
【问题描述】:
我正在尝试创建一个新文件夹“Abc”,然后将图像从 url 下载到它。它在 Android 中运行良好,我在 Gallery 中看到文件夹/图片,但在 ios 中看不到。
添加了一些警报,这让我觉得文件夹和图像在 ios 中下载得很好(触发了成功功能),但我无法在任何地方看到该文件夹。此外,我正在尝试从应用程序本身共享该图像,并且该功能也没有选择本地图像(同样,在 Android 中工作正常)。我在 Phonegap 3.5 中使用最新版本的文件和文件传输插件
这是我正在使用的代码:
//in onDeviceReady
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFSSuccess, null);
function onFSSuccess(fileSystem) {
fileSystem.root.getDirectory("Abc",{create:true, exclusive: false},gotDir,onError);
}
function gotDir(d){
DATADIR = d;
alert(DATADIR.toURL());
}
var ft = new FileTransfer();
ft.download(imgurl, dlPath, function(entry) {
console.log("download complete: " + entry.fullPath);
alert(entry.fullPath);
},
function(error) {
alert(error.code);
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
}
);
DATADIR.toURL() 返回:
安卓:
file:///storage/emulated/0/Abc/
ios:
file:///var/mobile/Applications/xxxx-xxxx-xxx-xx-xxx/Documents/Abc/
entry.fullPath 返回:
安卓:
/Abc/filename.ext
iOS:
/Abc/filename.ext
但我在 iphone (ios 7) 上的 Documents 中的任何地方都看不到“Abc”文件夹。
有什么建议吗?
谢谢!
更新:
当我在模拟器中运行它时,我可以浏览到 mac 上的新目录(通过 ~/Library/Application Support/iPhone Simulator),并且可以通过 SocialShare 插件进一步访问它,但不能在实际设备中访问它(尝试过2)。
另一个更新:
我现在可以对下载到设备新文件夹中的图像使用共享功能。但是,我仍然无法浏览创建的新文件夹。如果它正在共享,则意味着该文件夹存在但无法访问。有什么想法吗?
【问题讨论】:
标签: ios file cordova directory