[expo-file-system] Support Web via OPFS Api
Thomas Steinbrüchel
Hello there,
As expo-file-system doesn't support web yet I had to come up with a solution for our file storage needs and thought it may be worth sharing here as a starting point to review web support and get an idea on how it could be implemented.
In the gist you can find the implementation of our FileSystemUtils, once for native (using expo-file-system) and once for web (using OPFS api) together with the interface contract to keep the method signatures and return types aligned/enforced.
With only a few line changes it would even be possible to add Web Worker Thread support without having to change ANY calling code :-).
Also blob uri handling and cleanup is also included (through a withFileUrl function + useFileUrl hook)
Edit; I'll soon update the gist to include the web worker approach with sync access handle so that safari 18 is also supported.