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

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 :

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

Thanks for your help :slight_smile:

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

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

I got this on package.json

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

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

1 Like

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

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.