Fetch the config file

Each Markdown file you create will be stored inside a new versioned structured data. The app needs a way to retrieve your files on the SAFE Network. If the app doesn't properly keep track of the data it creates using the low-level API, the user might be unable to retrieve and delete data stored by the app.

The solution is to generate a random "user prefix" and store it inside a config file located in the app's root directory. This random user prefix will be used to assign IDs to the files you create. The ID of each file will be based on your user prefix and the filename. That way, the app can reuse the same random user prefix instead of creating a new one for each file.

In order to keep track of the filenames, the app creates a file index that will be used to store the names of all your files. This file index will be stored inside an unversioned structured data with an ID based on your user prefix.

Therefore, the app is able to retrieve all your files simply by retrieving your user prefix, which will be stored inside a config file located in the app's root directory. Using your user prefix, the app can fetch your file index, which contains the names of all your files. Individual files can be fetched using your user prefix and the filename.

Generate a user prefix

The app generates a random "user prefix" that will be used to assign IDs to the files you create.