Storage
The file system is a set of storage isolated by minigame and user dimensions provided by OpenPaaS, along with a corresponding set of management APIs. Use sud.getFileSystemManager() to obtain the globally unique file manager. All file system management operations must go through the manager.
Files are divided into two main categories:
- Code package files: files added within the project directory.
- Local files: files generated locally by calling APIs, or downloaded over the network and stored locally.
Local files are further divided into:
Local temporary files
Local cache files
Code Package Files
Because of the code package size limit, code package files are suitable for files needed at first load. For larger content or files that need to be dynamically replaced, it is not recommended to add them to the code package; instead, download them locally with the download APIs after the minigame starts.
Accessing Code Package Files
Code package files are accessed by writing the file path starting from the project root directory; relative path notation is not supported.
Modifying Code Package Files
Files inside the code package cannot be dynamically modified or deleted after runtime. Modifying code package files requires publishing a new version.
Local Files
Local files refer to a dedicated file storage area that is created after a user adds the minigame to their phone, isolated by user dimension. That is, on the same phone, each user cannot access the files of other logged-in users, and files across different appIds of the same user cannot access each other.
Local Temporary Files
Local temporary files can only be generated by calling specific APIs; content cannot be written to them directly. Once a local temporary file is generated, it is only valid within the current lifecycle and becomes unavailable after a restart. Therefore, do not store the path of a local temporary file for later use. If you need to use it next time, you can convert the local temporary file into a local cache file or local user file via the FileSystemManager.saveFile or FileSystemManager.copyFile API.
Local Cache Files
Local cache files can only be generated by calling specific APIs; content cannot be written to them directly. Once a local cache file is generated, it remains available after a restart. Local cache files can only be obtained by saving a local temporary file via the FileSystemManager.saveFile API.
Modifying Local Cache Files
Developers can modify local files via FileSystemManager.readFile and FileSystemManager.writeFile.
See Client API for details.
