PhoneGap resolveLocalFileSystemURL问题(错误5)

Nic*_*ino 2 filesystems cordova

我正在使用PhoneGap Build来构建iOS应用程序并使用weinre进行调试.到现在为止还挺好.

我正在尝试使用媒体捕获和文件API来捕获视频并获取其base64表示.我可以打开录像机,拍摄视频,然后返回.问题是我无法获得resolveLocalFileSystemURL来打开给定的路径.每次它返回错误代码为5时,我似乎无法找到关于这意味着什么的单一答案.这是在真实设备上运行,因此它不是模拟器的问题.

我已经检查了我可以通过Google和Stack Overflow找到的每个帖子我已经阅读了博文和其中的评论.在这个问题上已经有好几天了.提出答案的每个人都使用Xcode--而不是Build--或者答案根本不适用于我.这是一件非常简单的事情,我无法弄清问题可能在哪里......

以下是我的代码.下面是控制台输出.

elements["media_video"].onclick = function(event) {
    navigator.device.capture.captureVideo(
        function(files) {
            for ( var i = 0 ; i < files.length ; ++i ) {
                var file = files[i];
                var name = file.name;
                var path = file.fullPath;
                var type = file.type;
                var lastModifiedDate = file.lastModifiedDate;
                var size = file.size;
                console.log(0, name, path, type, lastModifiedDate, size);
                var reader = new FileReader();
                reader.onloadend = function(event) {
                    console.log(3, event.target.result);
                };
                window.resolveLocalFileSystemURL(
                    path,
                    function(entry) {
                        console.log(1, entry.name);
                        reader.readAsDataURL(entry);
                        // send base64 data to server
                    },
                    function(error) {
                        console.log(2, error.code);
                    }
                );
            }
        },
        function(error) {},
        {
            limit:  1
        }
    );
};
Run Code Online (Sandbox Code Playgroud)

0"capturedvideo.MOV""/ private/var/mobile/Applications/[application uuid] /tmp/capture/capturedvideo.MOV""video/quicktime"1409866447000 205788

2 5

编辑1 我没有使用Xcode的Mac,这就是我选择基于云的服务的原因.

在iOS v7.1.2上编辑2测试.

Ker*_*tts 10

采取/private离初始路径(在较旧版本的IOS [<7],则需要取下/localhost的路径的部分).

出于某种原因,iOS认为private即使完整路径最终落入您的沙箱,您也无法访问任何目录.令人沮丧的调试,至少可以说,但一旦你知道要寻找什么,这是一个简单的解决方案.


2014年8月5日编辑6:06:


我刚才注意到你也没有提供一个URL方案 - 你需要file://在你的路径前面加上,否则你会得到这个特殊的错误.在调用之前,您的最终路径应如下所示resolveLocalFileSystemURL:

file:///var/mobile/Applications/[application uuid]/tmp/capture/capturedvideo.MOV
Run Code Online (Sandbox Code Playgroud)