将图像从 Photolibrary 复制到文件系统 - 错误 1000

Copying Image from Photolibrary to Filesystem - Error 1000

这是我使用 cordova 相机插件从照片库中 select 图片的功能;

$('#select').click(function() {
        navigator.camera.getPicture(onSuccess, onFail, { quality: 50, 
                                                        destinationType: Camera.DestinationType.FILE_URL, 
                                                        sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
        function onSuccess(imageURI) {

            window.resolveLocalFileSystemURL(imageURI, function(entry) {
                debugger;
                fs.root.getDirectory('InsectFinder', {}, function(dirEntry) {
                    debugger;
                    dirEntry.getDirectory('FundmeldungPictures', {}, function(dirDirEntry) {
                        debugger;
                        var newFileName = fundmeldungInsectId + "_" + (images.length+1) + ".jpg";                           
                        entry.copyTo(dirDirEntry, newFileName, function(newEntry) {
                            debugger;
                            var img = {name: newFileName, id: images.length+1};
                            images = images.concat(img);
                            bilderDataSource.data(images);
                            console.log("yay");
                        }, errorHandler);
                    }, errorHandler);
                }, errorHandler);
            }, errorHandler);
        }
        function onFail(message) {
            console.error('Failed because: ' + message);
        }
    });

问题是,当我进入 copyTo 函数时,出现代码为 1000 的错误。 我用手机摄像头拍摄图像时使用了相同的代码,并且工作正常。

编辑: 这是我请求文件系统的函数。我将 fs 声明为一个全局变量,这样我就可以在不同的时间访问这个文件系统。

window.requestFileSystem(window.PERSISTENT, 100*1024*1024, function(filesystem) {
                console.log("opened file system: " + filesystem.name);
                fs = filesystem;

            }, errorHandler);

编辑: 当我调试 copyTo 函数时,我认为它在这一行失败了:

var messages = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);

消息在此函数后未定义

在接下来的错误处理中,我得到了如下流程消息:

"S01 File1981269537 {"isFile":false,"isDirectory":true,"name":"FundmeldungPictures","fullPath":"\/InsectFinder\/FundmeldungPictures","filesystemName":"persistent","filesystem":1,"nativeURL":"file:\/\/\/storage\/emulated\/0\/InsectFinder\/FundmeldungPictures\/"}"

我通过返回图像的 DATA_URL 并将其写入文件系统中的新文件解决了这个问题。