【发布时间】:2014-02-13 19:52:12
【问题描述】:
我使用 phonegap/cordova (3.3.0) 访问 iOS 相机功能。 相机源设置为库,获取库条目。 如果我从收到 uri 的库中选择一个文件,我想用它来复制文件。
navigator.camera.getPicture(capSucc, capFail,{
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
});
function capSucc(fileURI){
cpyCtrl.copy(fileURI);
}
然后我尝试通过 fileURI 从 localFileSystem 获取文件。我收到一个 fileEntry,但它在此文件的复制指令处停止:
window.resolveLocalFileSystemURI(sourceFile, onSuccess, onError);
function onSuccess(fileEntry) {
var root = localStorage.rootPath; //root : /Users/xcode/Library/Application Support/iPhone Simulator/6.0/Applications/2102E3A0-7F22-4C56-A693-EF3CF2A7620F/Documents/
var parentName = root.substring(root.lastIndexOf('/')+1);
var parentEntry = new DirectoryEntry(parentName,root);
fileEntry.copy(parentEntry, "myPic.jpg", succ, fail); //this is where the problem occurs
}
function succ(entry){
alert("copy");
}
function fail(message){
alert("fail");
}
function onError(message){
alert("fileFail");
}
}
文件的目的地应该是文件系统的根路径。
【问题讨论】:
标签: cordova