0

这是一个正在调用的 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);
    }
4

1 回答 1

0

没关系,Phonegap fileTransfer14 小时前更新了方法……

http://community.phonegap.com/nitobi/topics/file_transfer_plugin_updated_to_0_4_2_on_phonegap_build

我生命中的两个小时,我永远不会回来。我没有提到昨天工作正常,我花了最后两个小时检查版本是否存在差异,但没有发现任何差异,然后把我的头发扯掉了。

于 2014-04-02T10:36:45.740 回答