KScript docs
EN

App folders: KScript.Storage

Where storage works

You may use KScript.Storage in scripts, desktop apps and the controllers of kscript serve. In a controller, the app's folders are the one place outside the site folder it can write to. Pages are read-only, so they can read from storage but not write.

The docs' "try it" boxes don't run KScript.Storage, because it writes outside the example's own folder.

Moving the folders

Two environment variables move the folders, which tests, portable installs and containers use:

  • KSCRIPT_STORAGE_ROOT moves every app's folders to <root>/<app>/<kind>, such as <root>/notes/data.
  • KSCRIPT_PROJECT_DATA_ROOT is the folder for relative auth and SQLite paths in kscript.json, instead of the project folder. A path that leaves it is an error.

Both need an absolute path. In Docker, put both on a volume, or users, sessions and stored files are lost when the container is recreated. The files kscript make docker writes do this for you (see Where a container keeps its data).

KScript.Cache keeps its file cache in the cache folder (see Caching).

Edit this page on GitHub