# File.readAsText never resolves

**URL:** <https://forum.ionicframework.com/t/file-readastext-never-resolves/85375>\
**Category:** ionic-v3\
**Created:** [April 4, 2017, 6:05pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375 "2017-04-04T18:05:45Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![alberosado](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alberosado/32/108175_2.png) [@alberosado](https://forum.ionicframework.com/u/alberosado)\
**Post date:** [June 16, 2017, 3:06pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/21 "2017-06-16T15:06:55Z")

</div>

sure it is, I’m debugging in an emulator with chrome inspect, although the Android SDK itself vary between platforms, probably the issue is there… but yeah, thanks for your time.

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [June 16, 2017, 3:15pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/22 "2017-06-16T15:15:54Z")

</div>

oki doki … for the record I tested this today on both iOS and Android real phone … just in case

---

<div class="post-metadata">

**Author:** ![Anacharsis](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@Anacharsis](https://forum.ionicframework.com/u/Anacharsis)\
**Post date:** [September 24, 2017, 5:41pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/23 "2017-09-24T17:41:31Z")

</div>

Thank you! I was looking for exactly this information 👍

---

<div class="post-metadata">

**Author:** ![fabiennb](https://avatars.discourse-cdn.com/v4/letter/f/e79b87/32.png) [@fabiennb](https://forum.ionicframework.com/u/fabiennb)\
**Post date:** [October 19, 2017, 1:41am UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/24 "2017-10-19T01:41:50Z")

</div>

Hello, I got this issue sometimes, not always and I can’t figure why yet.  
We use FileTransfer, Zip and File from Ionic native.  
My code looks like this:

```auto
const fileTransfer: FileTransferObject = self.transfer.create();
fileTransfer.download(url, file.dataDirectory + FILE_NAME)
	.then(() => {

		self.zip.unzip(file.dataDirectory + FILE_NAME, file.dataDirectory)
			.then((result) => {

			if (result == 0) {
					
					// Always get here but sometimes, readAsText never resolves...
					
					file.readAsText(this.file.dataDirectory, NOM_FICHIER_XML)
						.then((data) => {
							
						})
						.catch((Error) => {
							
						})
			}
		}
	}

```

ionic info:

```auto
cli packages: 

    @ionic/cli-utils : 1.13.0
    ionic (Ionic CLI) : 3.13.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms : android 6.3.0
    Ionic Framework : ionic-angular 3.7.1

System:

    Android SDK Tools : 26.0.1
    Node : v6.9.5
    npm : 4.2.0
    OS : Windows 7

```

Config.xml:

```auto
<plugin name="cordova-plugin-file" spec="4.3.3" />
<plugin name="cordova-plugin-zip" spec="3.1.0" />
<plugin name="cordova-plugin-file-transfer" spec="1.6.3" />

```

Package.json:

```auto
"@ionic-native/file": "4.3.1",
"@ionic-native/file-transfer": "4.3.1",
"@ionic-native/zip": "4.3.1",

```

The workaround about placing cordova.js after polyfills.js works for us, but it kind of break the splash screen (where the splash screen is rapidly replaced with a gray background at startup).

Any idea why the File.readAsText() doesn’t resolve sometimes ?

Thanks.

---

<div class="post-metadata">

**Author:** ![seevoovapp](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@seevoovapp](https://forum.ionicframework.com/u/seevoovapp)\
**Post date:** [November 14, 2017, 11:10am UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/25 "2017-11-14T11:10:29Z")

</div>

Hey.  
can you explain how to read file using http?

---

<div class="post-metadata">

**Author:** ![skydive](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@skydive](https://forum.ionicframework.com/u/skydive)\
**Post date:** [November 15, 2017, 6:24pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/26 "2017-11-15T18:24:56Z")

</div>

@seevoovapp, like this;

> this.http.get(yourFile)  
> .map((res: Response) =\> res.text())  
> .subscribe(data =\> {  
> // data is the content of your file  
> //do something with it  
> },  
> error =\> {  
> console.log("Error reading config file " + error.message + ", " + error.code);  
> })

---

<div class="post-metadata">

**Author:** ![twain](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@twain](https://forum.ionicframework.com/u/twain)\
**Post date:** [December 7, 2017, 9:36pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/27 "2017-12-07T21:36:03Z")

</div>

Still have this Problem

ionic info

```auto
cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms : android 6.3.0
    Ionic Framework : ionic-angular 3.9.2

System:

    Node : v6.12.0
    npm : 3.10.10 
    OS : Linux 4.13

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

```

---

<div class="post-metadata">

**Author:** ![jamil\_etq](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jamil\_etq](https://forum.ionicframework.com/u/jamil_etq)\
**Post date:** [December 18, 2017, 7:09pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/28 "2017-12-18T19:09:56Z")

</div>

This issue is replicated again after the android webview updated to [63.xxx](http://63.xxx)

---

<div class="post-metadata">

**Author:** ![maheshkumawat24](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@maheshkumawat24](https://forum.ionicframework.com/u/maheshkumawat24)\
**Post date:** [February 23, 2018, 6:11pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/29 "2018-02-23T18:11:39Z")

</div>

Try to put some Timeout and test.

---

<div class="post-metadata">

**Author:** ![Tommertom](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Tommertom](https://forum.ionicframework.com/u/Tommertom)\
**Post date:** [March 9, 2018, 7:12am UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/30 "2018-03-09T07:12:32Z")

</div>

Hi

problem with me as well. Used to work, now not anymore. Switching cordova.js against polyfill.js in index.html seems to fix it (Android Tablet). Such a horrible bug to find and thank you all here for publishing the fix!

```auto
C:\Gebruikers\Developer\xxxx>ionic info

cli packages: (C:\Users\xxxxAppData\Roaming\npm\node_modules)

    @ionic/cli-utils : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms : android 6.2.3
    Ionic Framework : ionic-angular 3.9.2

System:

    Node : v6.11.2
    npm : 5.6.0
    OS : Windows 7

Environment Variables:

    ANDROID_HOME : C:\Gebruikers\Developer\Android\Android\sdk

Misc:

    backend : pro

```

---

<div class="post-metadata">

**Author:** ![olivier\_schmid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/olivier_schmid/32/132317_2.png) [@olivier\_schmid](https://forum.ionicframework.com/u/olivier_schmid)\
**Post date:** [March 20, 2019, 2:22pm UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/31 "2019-03-20T14:22:27Z")

</div>

Any news on that issue? Importing cordova.js after polyfills.js seems to work but i’me not sure if that could cause other side effects.

“@ionic-native/file”: “^4.19.0”

---

<div class="post-metadata">

**Author:** ![buda701](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@buda701](https://forum.ionicframework.com/u/buda701)\
**Post date:** [August 28, 2019, 11:38am UTC](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375/32 "2019-08-28T11:38:12Z")

</div>

polyfills.js  
cordova.js

in that order incredibly it works

[Previous page](https://forum.ionicframework.com/t/file-readastext-never-resolves/85375.md?page=1)
