这是一个被调用的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);
}
答案 0 :(得分:0)
没关系,Phonegap 14小时前更新了fileTransfer
方法......
http://community.phonegap.com/nitobi/topics/file_transfer_plugin_updated_to_0_4_2_on_phonegap_build
我生命中的两个小时我永远不会回来。我忽略了这一点,昨天工作正常,我花了最后两个小时检查版本的差异,找不到任何东西,撕掉我的头发。