Fetch file index
The app fetches the file index associated with your user prefix. Each Markdown file you create is stored inside a new unversioned structured data. The ID of each file is based on your user prefix and the filename. Your file index contains the names of all your files. Individual files can be fetched using your user prefix and the filename.
Contents

Get a data ID handle
The app obtains a data ID handle for the unversioned structured data (type tag 500) that contains your file index.
POST /data-id/structured-data
safeDataId.getStructuredDataHandle(ACCESS_TOKEN, INDEX_FILE_NAME, 500)
The name of your file index is based on your user prefix and the string "#index".
const INDEX_FILE_NAME = btoa(`${USER_PREFIX}#index`);
Get a structured data handle
The app tries to obtain a structured data handle using the data ID handle of your file index.
GET /structured-data/handle/:dataIdHandle
safeStructuredData.getHandle(ACCESS_TOKEN, handle)
The app stores the structured data handle in a global variable.
INDEX_HANDLE = sdHandle;
Fetch the file index
The app tries to read the structured data that contains your file index using the structured data handle previously obtained.
GET /structured-data/:handleId/:version?
safeStructuredData.readData(ACCESS_TOKEN, sdHandle, '')
If the app is able to read the structured data, it parses your file index and stores it in a global variable.
FILE_INDEX = payload;
Create a file index
If the app is unable to read the structured data, it means that your file index hasn't been created yet. Therefore, the app will create an unversioned structured data (type tag 500) with an ID based on your user prefix and the string "#index". Your file index is encrypted using the cipher options handle previously obtained.
POST /structured-data
safeStructuredData.create(ACCESS_TOKEN, INDEX_FILE_NAME, 500,
new Buffer(JSON.stringify({})).toString('base64'), SYMETRIC_CYPHER_HANDLE)
The app saves your file index by sending a PUT request to the SAFE Network.
PUT /structured-data/:handleId
safeStructuredData.put(ACCESS_TOKEN, INDEX_HANDLE)
Finally, the app stores your file index in a global variable.
FILE_INDEX = payload;
Last updated
Was this helpful?