JoCa96 opened a new issue #453: URL: https://github.com/apache/cordova-plugin-file/issues/453
# Bug Report Hi, we had this plugin in our Capacitor project as a dependency of `cordova-plugin-advanced-http`. It is not possible to use the [Browsers File API](https://developer.mozilla.org/en-US/docs/Web/API/File/File) with this plugin in Capacitor on iOS. The following snippet will not work correctly: ```javascript var file = new File(["foo"], "foo.txt", { type: "text/plain", }); ``` ## Problem The `cordova-plugin-file` is overwriting the global/globalThis/window File variable. I never actively used this Plugin, but skimmed through the docs and it doesn't seem like this behaviour is intended. ### What is expected to happen? I expect to be able to use the Browsers `File` API as described by [MDN](https://developer.mozilla.org/en-US/docs/Web/API/File/File) to create a File instance. ### What does actually happen? An incorrect File instance is created, which can not be used as describe by [MDN](https://developer.mozilla.org/en-US/docs/Web/API/File/File) to create a File instance. ## Information We are only building an iOS App, so I can only confirm this bug for iOS. ### Command or Code Create an Capacitor iOS project and install the `cordova-plugin-file` package. Build the iOS app and use XCode to build and run the App on an iPhone/iPad connected via USB. Use Safari DevTools to debug the Capacitor App and run the following snippet. Inspect the `file` variable or inspect the `File` protoype's constructor and you will notice that it is not the Browsers native `File` API. ```javascript var file = new File(["foo"], "foo.txt", { type: "text/plain", }); ``` ### Environment, Platform, Device * Capacitor 2.4.6 * iOS 14.3 * iPhone 8 ### Version information ```json "@capacitor/cli": "2.4.6", "@capacitor/core": "2.4.6", "@capacitor/ios": "^2.4.6", "ionic": "^5.4.14", "@ionic/angular": "^5.4.1", "@ionic/angular-toolkit": "~2.0.0", "ionic-native": "^2.9.0", "@ionic-native/file-transfer": "^5.29.0", "cordova-plugin-file": "^6.0.2", "cordova-plugin-advanced-http": "^2.2.0", ``` ## Checklist <!-- Please check the boxes by putting an x in the [ ] like so: [x] --> - [x] I searched for existing GitHub issues - [x] I updated all Cordova tooling to most recent version - [x] I included all the necessary information above ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
