Save a new version

When you edit an existing file, a new version is stored inside the structured data associated with that file.

Contents

Save a new version

Get a data ID handle

The app obtains a data ID handle for the versioned structured data (type tag 501) that contains the file you just edited. The ID of this structured data is based on your user prefix and the name of the file.

Get data ID handle

POST /data-id/structured-data
store.js
safeDataId.getStructuredDataHandle(ACCESS_TOKEN, btoa(`${USER_PREFIX}:${filename}`), 501)

Get a structured data handle

The app obtains a structured data handle using the data ID handle of the file you just edited.

Get structured data handle

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

After obtaining a structured data handle, the app drops the data ID handle of the file you just edited.

Drop data ID handle

DELETE /data-id/:handleId
store.js
safeDataId.dropHandle(ACCESS_TOKEN, dataIdHandle)

Update the file

The app stores a new version inside the structured data associated with the file you just edited. It's encrypted using the cipher options handle previously obtained.

Update structured data

PATCH /structured-data/:handleId
store.js
safeStructuredData.updateData(ACCESS_TOKEN, handleId, payload, SYMETRIC_CYPHER_HANDLE)

This new version includes the Markdown content and the current time (encoded as a base 64 string).

store.js
const payload = new Buffer(JSON.stringify({
  ts: (new Date()).getTime(),
  content: data
})).toString('base64');

The app saves the new version of your file by sending a POST request to the SAFE Network.

Save structured data

POST /structured-data/:handleId
store.js
safeStructuredData.post(ACCESS_TOKEN, handleId)

Fetch all versions

The app refetches all the versions of the file and displays them in the UI.

Fetch all versions

results matching ""

    No results matching ""