For the File API:
https://developer.mozilla.org/en-US/docs/Web/API/File#browser_compatibility
There is support since Android Webview 37 (basically since Android 5.0 /
API 21, assuming default AOSP packages) and iOS 9. Our minimum targets
exceeds both of these. It will be an API change but we might be able to
get rid of `File` override altogether and use the standard browser
`File` object. I don't see anything that actually requires a home-brewed
implementation here. Just our implementation doesn't follow the
standards, particularly in the constructor arguments.
The one unknown is to make a `File`, we need the file data in-memory,
since W3C spec File is also a Blob. It would mean that
`fileEntry.file(...)` would need to actually load in the file contents
to produce a valid W3C file, which is less than ideal especially for
anyone using this API just to get some metadata regarding the file.
Alternatively we could maybe just rename our File symbol as to not clash
with the native browser symbol. We've already decided in the past that
since the plugin is implementing an obsolete standard that will not ever
become implemented by
browser vendors, we can deviate from W3C where necessary, at least in
the parts that involve Filesystem APIs... Plugin users has no real value
in using Cordova's File constructor directly so this should be a
low-risk / high-value change.
For the FileReader API, this API does use the cordova bridge, so I think
replacement is necessary, especially if we keep the File API as-is (with
a symbol rename). I'm not sure how far we can get to extending the class
because we will likely need to override each read API anyway. So I think
the answer here is to simply implement the missing APIs. But we also
should ensure we keep compatibility with using the FileReader with Blob
and the native-browser File objects by delegating read calls with those
objects to the native-browser FileReader perhaps.
The FileReader part of W3C is still living unlike the FileSystem parts,
so it's worth ensuring that we are W3C compliant here.
Just my own thoughts.
On 2024-12-10 04:46, Lucas Bourgeois wrote:
Hi,
Following the comment of breautek :
https://github.com/apache/cordova-plugin-file/issues/572#issuecomment-2528991987
I would like to submit a discussion around File, FileReader implementation.
I understand the past needs but i think it's a major issue to have JS api
not following standards.
I think it isnt an edge case to manipulate File, FileReader in a JS env,
even more in a cordova phone app.
It's a use case to be able to manipulate a File to discuss with an API.
it's also quite disturbing to use FileReader with unexpected behavior from
standards
Everything is nearly listed here :
https://github.com/apache/cordova-plugin-file/issues/316
https://github.com/apache/cordova-plugin-file/issues/572
Regards,
Lucas
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org