Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14110

Cordova Plugin File not reading large json files correctly - android

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 6.0.1
    • Fix Version/s: None
    • Component/s: cordova-plugin-file
    • Labels:
    • Environment:

      cordova version: 7.1.0

      cordova-android: 7.1.0

      cordova-ios: 7.1.0

      Description

      When reading a large json file (293kb), readAsText renders string incorrectly, adding duplicate text after the file's text ends and breaking json structure. JSON.parse the text fails due to this. It hangs and fails.

      const root = `${this.window.cordova.file.applicationDirectory}www/assets/`;
      
      this.window.resolveLocalFileSystemURL(this.root + fileName,
      
      (fileEntry: FileEntry) => {
      
      fileEntry.file(file => {
      
      const reader = new (<any>this.window.cordova).FileReader();
      
      reader.onloadend = function () {
      console.log(JSON.parse(this.result));
      };
      
      reader.readAsText(file);
      });
      });
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              JoelHenryUnifii Joel Henry
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: