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

Cordova Plugin File not reading large json files correctly - android

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 6.0.1
    • None
    • cordova-plugin-file
    • 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

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

            Dates

              Created:
              Updated: