0
這是一個正在調用的onSuccess函數,但moveTo
方法沒有達到預期的效果。它應該將我的映像移動到file:/// storage/sdcard0/PhotoscanPhotos /,但調試警報僅顯示//PhotoscanPhotos
。Cordova/Phonegap moveTo不能獲取根目錄
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);
}