File readAsText not working

I tried to use the file-plugin like described here:

Writing to a file seems to work. But when trying to read the file readAsText never resolves exactly as described here: File.readAsText never resolves

Is there any update to this topic regarding the latest Ionic / Capacitor version?

Things to note:

  • The link you pointed to is for Cordova Plugins, but you’ve indicated Capacitor.
  • Capacitor provides it’s own FileSystem API, which can be found here
  • What have you tried? Can you share the code you are using? We cannot help without any sample code.

If you are using angular, there is a known issue with zone.js that makes Filereader not work on Capacitor apps.
You can see more information and workarounds here

Thanks for your response. I was not aware that there is a Capacitor FileSystem API.

When searching for “file” on the Ionic doc’s page I found the description of the Cordova File plugin: I think it’s a little bit misleading that there is an explanation how to install this plugin with capacitor instead mentioning that this plugin does not work with capacitor.

cordova-plugin-file works with Capacitor, but some of its features don’t work if you also use zone.js because of zone.js overriding FileReader and the plugin also overrides it and causes problems.

So it depends on if your project uses it or not, and most angular projects use it.
But you can use Capacitor with any frameworks and without zone.js

Capacitor is a separate project from Ionic, it has its own site with its own docs

You can still use the cordova plugin by rewriting the file reader.