这是一个正在调用的 onSuccess 函数,但该moveTo
方法没有产生预期的效果。它应该将我的图像移动到 file:///storage/sdcard0/PhotoscanPhotos/ 但调试警报只显示//PhotoscanPhotos
.
function movePhoto(fileEntry) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSys) { //onsuccess
fileSys.root.getDirectory("PhotoscanPhotos", {create: true, exclusive: false}, function(dir) {
var guid = guidGenerator();
Speicher.setPhotoFolder(dir.fullPath);
alert(dir.fullPath); //debugging
fileEntry.moveTo(dir, (guid + "foto.jpg"), onMoveSuccess, onFail);
}, onFail);
}, onFail);
}
有人知道我做错了什么吗?它是 Phonegap 3.1 API 文档的虚拟副本。我的配置文件肯定是正确的。
提前致谢
编辑:为了完整性,其余代码:
function takePicture() {
var code = $("#txtCode").val();
if(!code){
alert("Zuerst EAN-Code scannen oder eingeben.");
return false;
}else{
ean = code;
}
navigator.camera.getPicture(onPhotoURISuccess, onFail,
{ quality: 100, destinationType: Camera.DestinationType.FILE_URI });
return true;
}
function onPhotoURISuccess(imageURI) {
createFileEntry(imageURI);
showImageList();
}
function createFileEntry(imageURI) {
window.resolveLocalFileSystemURI(imageURI, movePhoto, onFail);
}
function movePhoto(fileEntry) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSys) { //onsuccess
fileSys.root.getDirectory("PhotoscanPhotos", {create: true, exclusive: false}, function(dir) {
var guid = guidGenerator();
Speicher.setPhotoFolder(dir.fullPath);
alert(dir.fullPath); //debugging
fileEntry.moveTo(dir, (guid + "foto.jpg"), onMoveSuccess, onFail);
}, onFail);
}, onFail);
}
function onMoveSuccess(entry) {
var image = {ean:ean, image: entry.fullPath, timestamp:convertDateToUTC()};
alert(image.image); //debugging
getPhotoFolder();
alert(numOfPhotosStored + " photos stored"); //debugging
images.push(image);
Speicher.setImages(images);
showImageList();
}
function onFail(error) {
alert(error.code + error.message);
}