LiquidPlayer / LiquidCore

Node.js virtual machine for Android and iOS
MIT License
1.01k stars 127 forks source link

Accessing static assets #178

Closed rgerd closed 4 years ago

rgerd commented 4 years ago

Hello,

Let's say I would like to use static assets (such as text files, png's, etc) in a node app on Android. I noticed we have service.getProcess().exposeHostDirectory, and it feels like this would be a good way to expose a folder containing the static assets, but it's unclear where such a folder should go.

Android also gives us context.getAssets(), but it seems that Android bundles their static assets in a way that's incompatible with the more traditional file directory structure model expected by node.

Is serving static assets a supported scenario in LiquidCore?

ericwlange commented 4 years ago

I'm afraid that assets won't be accessible through the filesystem. IIRC, android stores them in some binary (zip?) format. You can only get access to them through context.getAssets().open(), which provides a read stream. Thus they are not part of the filesystem, per se, so they won't be accessible using fs operations. This is a good feature request, though. I can see creating an API method that calls back to Android to get stream access to an Android asset.

rgerd commented 4 years ago

Got it, makes sense. Thank you.