Besides JSON documents, the document server can store blobs. Blobs are immutable byte sequences. A blob's token is its SHA 256 hash, written as 64 hex digits.
Checks if a blob exists on the store without retrieving it.
Retrives the blob with the given token.
Retrives the blob with download headers. Browsers typically save the blob to a download folder rather than displaying it.
Stores a blob. The content may be any sequence of bytes.
The blob token is the SHA256 sum of its bytes. The client submitting the blob may therefore precalculate the blob token before the blob is saved.
The blob store stores byte sequences only. If you want to store metadata, create a document with the metadata, and link the blob from there.
Using GenericBackend.js, blobs can be uploaded as follows:
const backend = new GenericBackend('https://viereck.ch/backend');
const data = ...; // string, blob, arraybuffer, or Uint8Array
backend.writeBlob(data, onDone, onError);
function onDone(token, request) {
...
}
function onError(errorCode, request) {
...
}
and downloaded as follows
backend.readBlob(token, onDone, onError);
function onDone(bytes, request) {
...
}
function onError(errorCode, request) {
...
}