birdofpreyru/react-native-static-server

Regarding handling bundled files in iOS

yunianzhuang opened this issue · 1 comments

Just as mentioned in the document, I have included the "webroot" folder in the Xcode project and retrieved the fileDir using resolveAssetsPath('webroot'). After that, I have created a server using new Server({fileDir, port: 8088, stopInBackground: true}) and am currently using it.

I have a requirement to download a file within the app and place it in a server's directory, and later access it through a service path. However, as far as I know, iOS bundled files are read-only and cannot be written or deleted. So, I'm not sure if adding the 'webroot' folder through Xcode is the correct approach. I would like to hear your advice.

From what I understand, the Documents directory in iOS is modifiable. Can I place the 'webroot' folder in the Documents directory, and how would I go about doing that? Additionally, can I set the server path to the Documents directory, so that I can download files to the Documents directory and access them through the server? Is this feasible?

Hey @yunianzhuang ,

You can keep webroot in the bundle, then use mod_alias to alias downloads URL to a writeable folder in the Documents directory. This way you'll keep pieces of your assets in different locations of the filesystem, some readonly, some writeable; but when you call to the server, it will be just different endpoints on the same domain.