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

Cordova Plugin File not reading large json files correctly - android

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            JoelHenryUnifii Joel Henry

            Dates

              Created:
              Updated:

              Slack

                Issue deployment