apache / apache/cordova-plugin-file

File, FileReader, Blob, ArrayBuffer are replacing Javascript native code instead of extending it.

Open
#572 6 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
744
Forks
754
Avg merge
3d 4h
Merged PRs (30d)
1

Description

# Bug Report

## Problem
Many of this plugin classes are overriding Javascript native classes instead of implements them properly

### What is expected to happen?
Plugin Blob, File, ArrayBuffer, FileReader classes should not replace Javascript native code and extend native JS API's

### What does actually happen?
For exemple, if i do a `const file = new File([], 'yoyo')`, I can't use Blob() functions like `file.arrayBuffer()` as File isn't extending Blob interface.
Also, file.name is an array containing a Blob item.

It cause unexpected behavior between browser web native Javascript File implementation and phone device cordova one.
In addition, we must add trash code to handle this.

## Information

https://developer.mozilla.org/en-US/docs/Web/API/Blob
https://developer.mozilla.org/en-US/docs/Web/API/File
https://developer.mozilla.org/fr/docs/Web/API/FileReader

### Command or Code

Just init a new File() or an new ArrayBuffer() and compare them with browser result, they are not as Javascript define them.

### Environment, Platform, Device

Cordova-android 11, Android 13 device, Chrome.

### Version information

"cordova-plugin-file": "^6.0.2",

## Checklist

- [ 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

Contributor guide

Open the contributing guide

Research direction

Start by locating the plugin implementations of File, Blob, ArrayBuffer, and FileReader and compare their behavior with the native JavaScript APIs linked in the report. Reproduce the File construction example on Cordova Android and in a browser; done means the plugin no longer replaces native behavior and File supports the expected Blob API and name value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.