Search code examples
javascriptstorageprogressive-web-apps

Reading files from internal storage in PWA


I'm in a bit unusual situation. We have a simple PWA that works like a small library with videos, files, etc. Only made for internal use at a convention. Since we need a large amount of data, and we can't rely on internet, I was thinking to put all files in a specific folder on the devices (3-4 android tablets) The information about the files (name, category, file path, etc.) are in a JSON-file on a server that is loaded on installation.

I don't need to write or access other files.

Just instead of loading xyz.mp4 from an online server, it should load from the internal storage.

Changing www.example.com/files/trailer.mp4 to /storage/emulated/0/files/trailer.mp4 obviously doesn't work.

Nearly all information I could find (File API, File system API, etc.) doesn't match my use-case.


Solution

  • You can host a small web server on the Android tablets using several apps, one example being Simple HTTP Server.

    Using the server app, you host the files locally, and consume them just like you would consume files from any other location in your PWA.