iOS上的Phonegap fileReader错误消息

Phonegap fileReader error message on iOS

本文关键字:错误 消息 fileReader Phonegap 上的 iOS      更新时间:2024-01-11

我正在下载一个包含4个文件的ZIP文件,提取它们,将CSV数据解析为SQL,并将其插入iOS应用程序。

4个文件中有3个处理良好,但其中一个(约17000行数据,文件大小约2MB)出现故障。这是我的readfile函数,以及来自序列化错误对象的JSON输出,由failed函数提供

    readFile = function( fileEntry ) {
        fileEntry.file(
            function( fileObject ){ 
                var reader = new FileReader();
                reader.onload = function( evt ) {
                    parseFile( fileObject.name, evt.target.result );
                };    
                reader.onerror = failed;
                reader.readAsText( fileObject );
            }
        );
    }

错误对象:

    {
        "type":"error",
        "bubbles":false,
        "cancelBubble":false,
        "cancelable":false,
        "lengthComputable":false,
        "loaded":0,
        "total":0,
        "target":{
            "_readyState":2,
            "_error":{"code":5},
            "_result":null,
            "_fileName":"/var/mobile/Applications/14323F76-D82C-4040-85AF-D37F2C73BE73/Documents/data/events.uk.data",
            "_realReader":{
                "readyState":0,
                "result":null,
                "onloadstart":null,
                "onabort":null,
                "error":null,
                "onprogress":null,
                "onloadend":null
            }
        }
    }

这个错误告诉我是哪个文件导致了问题,但没有有用的消息,唯一看起来有用的是_error: {code: 5}

编辑

根据此URL:https://developer.mozilla.org/en-US/docs/Web/API/FileError

值为5的HTML文件错误如下:

ENCODING_ERR|5| URL格式不正确。请确保URL完整有效。

有人知道问题出在哪里吗?或者如何获得更好的错误信息?

发现问题后,我查看了我的源文件(17000行美元符号分隔的数据,因为我不能使用逗号),我有一些无赖的括号(),感叹号!和英镑符号£。

移除这些修复了问题。

考虑到我使用$来分隔我的值,其中哪一个会真正阻止FileReader读取?