Hello, I have a huge json file in my project and I am trying to parse it at runtime instead of include it in JS bundle. Ideally it should be stringified and base64 compressed into a plain text asset, then shipped with the apk/ipa.
However I have not found any way to do this with Asset API. Any suggestions? Thanks a lot
JSON is already text so base64 wouldn’t be compressing it? Regardless, you can have it as a .txt file in your project, Expo.Asset.fromModule(require(..,))
should give you an Asset
version of it. Then you can use Expo.FileSystem.downloadAsync(...)
to download it from the remote URI to a file then read that with Expo.FileSystem.readAsStringAsync(...)
. If you include it in assetBundlePatterns
in your ‘app.json’ it could be bundled with the .apk.
Thanks for your response, I tried this way but always get the error:
The snack is here: demo-text-asset - Snack
P/S: I am using lz-string to compress the file then base64 it
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.