-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileReader API not firing #1564
Comments
Can you provide a sample project? |
Okay, so in the sample project it works. Guess the problem lies somewhere in the use of dropbox combined with promises and the filereader. I shall investigate further and when I find something I'll let you know! |
@jcesarmobile, apparently the problem is in the cordova-plugin-file plugin. |
But on the plugin itself or only when using it with Capacitor? |
When using it with capacitor it prevents FileRead from firing events. |
Looks like some problem with zone.js, but not sure why it only affects Capacitor and not Cordova If I log the FileReader object I get this results: Capacitor with Ionic Cordova with Ionic Capacitor without framework Cordova without framework The If we take zone.js (angular/ionic) out of the equation it works fine. |
Found this ionic-native issue danielsogl/awesome-cordova-plugins#505 Now I know why this isn't an issue on Cordova, |
Yeah, I took a look at the angular zone.js file, and it seems the have done some bug fixes regarding cordova. The also have zone.js patch for cordova here: https://github.com/angular/zone.js/blob/master/dist/zone-patch-cordova.js |
@jcesarmobile Edit: this worked for me danielsogl/awesome-cordova-plugins#505 (comment) |
@jcesarmobile, thanks for the tip. Loading EDIT: Loading |
You can try this. export function getFileReader(): FileReader {
const fileReader = new FileReader();
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
return zoneOriginalInstance || fileReader;
}
...
let newInstance = getFileReader(); |
I can confirm @tripodsgames 's solution is working for me. |
Thank you for the workaround @tripodsgames saved me. Maybe time for an official fix? |
This solution's working for me too, but after using it, I can see that the UI's loading slower than before(it's now display the text "back" then change to the icon). Does anyone else get that bad peformance or just me? |
@tripodsgames 's solution worked like charm. Thank you so much. |
closing since this is a zone.js bug related to changing cordova-plugin-file's |
I have this problem with Ionic V4 and capacitor without the cordova-plugin-file, use just a FileReader object and the problem is still present. If you use the hack, it works but there is a very bad performance, i made tests in a galaxy s7 edge:
|
I have been hitting my head for almost a week now over this issue using Ionic 6, and finally this solution came to the rescue. |
You saved my life bro, thanks a ton |
You saved someone's else life here as well, Thanks man I waste a lot of time on this. |
@tripodsgames Thanks!!! Adding a few more lines - FileReader onload not geeting called in android SOLVED
|
If you have plugins that rely on FileReader working correctly, using snippets from the getFileReader() code mentioned above, I have a solution Add to app.module.ts:
or add the above code to another file and import the file, not the class. This is a hack but it means that when calling |
Worked for me after days searching for a solution! Tks @tripodsgames ! |
It's working to me. Thanks a lot! |
Thanks to you and @tripodsgames the fix saved me, took me 4 days to finally come across this solution and it works! |
Thanks @tripodsgames |
BTW if you the change detection takes to long call detectChanges() from ChangeDetecotrRef FYI import ChangeDetectorRef from "@angular/core" |
Thanks @tripodsgames , this is IT. |
still saving lives and nerves even after almost a year... Thanks man |
@tripodsgames Thank you!!!! Dear google, please rank this higher in search results..... k thanks. |
Thank you so much! I had been fighting with this issue for days. This resolved it! Thank you thank you thank you! Ionic Version: 6.13.1 On Android App |
Thank you very much, worked for me! |
im a nooby, where to I have to put that code? Into the FileReader file or my ts file? |
Using that method you need to use that function instead of using FileReader normally. If you use the method I suggested it means you can use it normally. |
I endup using "Capacitor/Filesystem" library to read the file that was written by using "@ionic-native/file/ngx". |
this is the way... great solution, thanks! |
Kudos to you and @tripodsgames! It actually drained me many many days to trace and this amazing patching is really proven and 100% working! |
using solution here: ionic-team/capacitor#1564 (comment)
Can Any one help m when i and Passing data to File instance the data get changes in IOS and Android in Android:- in IOS :- i want same as android in IOS |
@tripodsgames thanks it is working |
The above provided solution regarding the __zone_symbol__originalInstance - filereader works but has problems with changedetection in angular since the onload method of the filereader gets executed outside angular-zone. We have overcome this issue by implementing a new filereader that decorates the __zone_symbol__originalInstance - filereader and executes the onload-method within the ngZone. Therefore, we extend the above provided solution by following code:
|
worked like a charm |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Description of the problem:
In my project I'm trying to read and convert a Blob downloaded from the dropbox api to a text string. When building my project using Cordova, the FileReader fires onload and onprogress events. When building using Capacitor, filereader does not fire any events at all.
Affected platform
OS of the development machine
Other information:
As suggested in other bug reports, I tried wrapping the FileReader in
and in
None helped. Cordova has no issues reading the file.
When I use
to read the file blob, it does work.
Capacitor version: 1.0.0-beta.24
The text was updated successfully, but these errors were encountered: