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

Fetch file index

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.

Get data ID handle

POST /data-id/structured-data
store.js
safeDataId.getStructuredDataHandle(ACCESS_TOKEN, INDEX_FILE_NAME, 500)

The name of your file index is based on your user prefix and the string "#index".

store.js
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

GET /structured-data/handle/:dataIdHandle
store.js
safeStructuredData.getHandle(ACCESS_TOKEN, handle)

The app stores the structured data handle in a global variable.

store.js
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.

Read structured data

GET /structured-data/:handleId/:version?
store.js
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.

store.js
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.

Create structured data

POST /structured-data
store.js
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.

Save structured data

PUT /structured-data/:handleId
store.js
safeStructuredData.put(ACCESS_TOKEN, INDEX_HANDLE)

Finally, the app stores your file index in a global variable.

store.js
FILE_INDEX = payload;

results matching ""

    No results matching ""