-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
file.ReadAsText() doesn't resolve a promise #3265
Comments
Same issue. |
Not yet, unfortunately... |
I tried the solution mentioned in [https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/2] |
There's no polyfill.js or cordova.js in my src/index.html. Where is this file exactly? |
Hi there, having the same issue, also combining ionic native file with capacitor because capacitor does not yet support writing blobs. |
I'm using ionic v3 that why am able to change the order of polyfills.js inside my index.html. |
Sadly no, the only way to change the file order would probably be to use a custom webpack build, but I don't really have time to learn how to do that. I decided to use Filesystem.readFile for this, which worked for android. However, on iOS, I have a problem. |
Still very relevant.
|
Hi everyone, |
Hi everyone, Following the @NajiLouisAct solution, I simply moved up Pollyfills before index.html on build options inside the angular.json.
After:
and it did the trick for me ! |
I have the same problem. The above did not work for me. I have Ionic 5. This is the only way I've been able to get it to work:
and then:
very weird but it worked for me. |
On the Capacitor and Ionic 5, sadly none of the work arounds mentioned here worked for me with readAsDataURL. |
Suddenly this function started to work on some Android10 devices... |
Hi not working on android 10 but working on android 7.1, any solution? |
Same here with latest versions: Ionic 5, Capacitor 2.4, Cordova File 6.0, Ionic Native File 5.28 :/ |
Making a local AJAX call seems to be the simplest solution. You can use Capacitor.convertFileSrc which turns the path to a URI you can use. Turns out something like this:
Tested on files roughly 5MB in size, works fine |
This seems related to #978, #505 and ionic-team/capacitor#1564 Why a 4 years old issue like this with a simple fix still isn't dealt with ? Is the fix sustainable ? |
It seems like I was able to find the source of the issue.
|
Using a combination of...
...finally cracked it for me. Working on both Android and iOS. Putting six hours into this solution sounds like I actually didn't have it as bad as some, so thank you all! |
Any updates or any solution for this? |
Facing the same with |
There has been no recent activity and this issue has been marked inactive. |
Thanks, pasting this code over the original onloaded function worked for me
|
Hello guys, if anyone is still facing this issue, I suggest a workaround solution.
|
Yes but it does not work in development mode (live-reload) since you get a |
I endup using "Capacitor/Filesystem" library to read the file that was written by using "@ionic-native/file/ngx". |
There has been no recent activity and this issue has been marked inactive. |
We randomly started experiencing this issue in Nov 2022 with the readAsArrayBuffer() function... not sure what changed or why it started happening. I followed advice in this thread & changed my .onloadend function to look like this and it seemed to fix it for me. Thanks everyone on this thread....
|
I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
file.readAsText returns nothing, but only when ionic app has built in production mode and deployed on Android device.
Expected behavior:
It's expected that this function must return a string with file content.
Related code:
this.file.readAsText(this.file.dataDirectory, 'myapp.log').then((logContent) => {
console.log('resolved', logContent);
resolve(logContent)
}).catch((errRes) => {
console.log('rejected', errRes);
reject(errRes);
Other information:
I can see in Android Studio that my file exists and I can download it from the device.
Moreover, I can see in Studio debugger in Java code, that this function is executed, result is not empty, but nothing returns to JS code:
public void readFileAs(final String srcURLstr, final int start, final int end, final CallbackContext callbackContext, final String encoding, final int resultType) throws MalformedURLException {
try {
LocalFilesystemURL inputURL = LocalFilesystemURL.parse(srcURLstr);
Filesystem fs = this.filesystemForURL(inputURL);
if (fs == null) {
throw new MalformedURLException("No installed handlers for this URL");
}
Ionic info: (run
ionic info
from a terminal/cmd prompt and paste output below):` Ionic CLI : 5.4.5
Ionic Framework : @ionic/angular 4.11.7
@angular-devkit/build-angular : 0.803.21
@angular-devkit/schematics : 8.3.21
@angular/cli : 8.3.21
@ionic/angular-toolkit : 2.1.1
Capacitor:
Capacitor CLI : 1.4.0
@capacitor/core : 1.4.0
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.1.0, browser 6.0.0
Cordova Plugins : cordova-plugin-file 6.0.2
Utility:
cordova-res : not installed
native-run : 0.2.9
System:
Android SDK Tools : 26.1.1
NodeJS : v13.0.1
npm : 6.13.2
OS : Windows 10
The text was updated successfully, but these errors were encountered: