# Name conflict between cordova-plugin-file and Javascript File interface

**URL:** <https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290>\
**Category:** Ionic Native\
**Created:** [March 17, 2020, 12:18pm UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290 "2020-03-17T12:18:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeliDroKieu](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DeliDroKieu](https://forum.ionicframework.com/u/DeliDroKieu)\
**Post date:** [March 17, 2020, 12:18pm UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290/1 "2020-03-17T12:18:43Z")

</div>

I can’t use the class `File` from `cordova-plugin-file` in my application cause there is another interface from `JavaScript` alse called `File`.

This name conflict impedes my app to access the `cordova-plugin-file` functions I want.

`File` from `JavaScript` has this description : “provide information about files and allows `JavaScript` in a web page to access their content”.

`File` from `cordova-plugin-file` should allow to read/write access to files residing on the device.

Here is my code :

```auto
import { File } from '@ionic-native/file';
export class Tab1Page {
  constructor(public file: File) {}
  ...
}

```

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [March 17, 2020, 2:56pm UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290/2 "2020-03-17T14:56:16Z")

</div>

What version of `ionic-native/file` is in your package.json?

I just tested things out and it still works fine.

If you’re worried about the types though, you can use the import/as approach

```auto
import { File as NativeFile } from '@ionic-native/file/ngx';

```

This way you will have `NativeFile` as the symbol, and it wont conflict with the built in

---

<div class="post-metadata">

**Author:** ![DeliDroKieu](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DeliDroKieu](https://forum.ionicframework.com/u/DeliDroKieu)\
**Post date:** [March 17, 2020, 5:10pm UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290/3 "2020-03-17T17:10:41Z")

</div>

I got this on package.json

`"@ionic-native/file": "^5.22.0"`

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [March 17, 2020, 7:22pm UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290/4 "2020-03-17T19:22:46Z")

</div>

Ok, so if you have 5.22, you’ll want to import things from `'@ionic-native/file/ngx';`

---

<div class="post-metadata">

**Author:** ![hrushikesh365](https://avatars.discourse-cdn.com/v4/letter/h/9fc29f/32.png) [@hrushikesh365](https://forum.ionicframework.com/u/hrushikesh365)\
**Post date:** [January 7, 2021, 5:16am UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290/5 "2021-01-07T05:16:32Z")

</div>

Declare file outside constructor. And you are good to go.  
import { File as cordova\_file } from ‘@ionic-native/file/ngx’;  
private file: typeof cordova\_file  
constructor(

---

<div class="post-metadata">

**Author:** ![sshar](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sshar](https://forum.ionicframework.com/u/sshar)\
**Post date:** [November 26, 2022, 6:45pm UTC](https://forum.ionicframework.com/t/name-conflict-between-cordova-plugin-file-and-javascript-file-interface/185290/6 "2022-11-26T18:45:38Z")

</div>

Hi,  
I would like to convert from base64 to File and in the device, I am using \*\*new File() \*\* ( javascript File API) then it is taking from the file plugin, not from js File API and conversion is going wrong, I tried the above approach like { File as FilePlugin } but it did not work.
