Blobs
The blob specification describes system schemas and validation conditions used when publishing binary application data. Blobs require their own materialization logic and these system schemas allow a node to distinguish blob documents from other application data and behave accordingly. Conceptually, blobs can be considered to be "attachments" on other documents. It is not intended that blobs alone serve as a general purpose content delivery system. We expect blobs to be attached to other documents via relation fields, replication and materialization logic can be optimized based on this assumption. See the blob http specification to read how blobs are materialized and served on a node.
System schemasβ
Blobβ
- Schema id:
blob_v1 - Representing a binary file
- Fields:
length: length of file in bytes (u64)mime_typeIANA mime-type (string)pieces: list of pieces which make up this blob (pinned relation list ofblob_piece_v1)
We designed blobs to be as generic as possible, giving developers the option to come up with their own application schemas on top of them. Information like a file name or path is optional meta data. If you need it, you can for example create a schema which contains a file_name, path field and a relation to a blob_v1 document. This can be interesting for building an application which materializes files into a specific folder structure, similar to BitTorrent.
- The claimed
lengthof ablob_v1document should be validated on publishing- This can be done by collecting all claimed pieces and calculating total length
- OR only validating that each
blob_piece_v1is the correct length and then validating thelengthvalue by checking the number of items in thepieceslist
- The claimed
mime_typeshould be validated - Validating blob pieces differs if they arrive through the Client API or Replication API
- Client API: all blob pieces should already exist before publishing the
blob - Replication API: a
blobmust exist with a relation to thepiecesbefore the pieces are accepted. This means we don't accept arbitrary blob data until we know the blob hash id, as we may want to choose to lazy load a blob's actual data.
- Client API: all blob pieces should already exist before publishing the
- The
piecesfield can not be empty - If a validation step fails, an error should be returned to the client and all related
blob_piece_v1and theblob_v1entries should be deleted
Blob Pieceβ
- Schema id:
blob_piece_v1 - Representing the (partial) binary data of a file
- Fields:
data: bytes contained in this blob piece (bytes)
- All blob pieces must be of maximum 256KB size
Notes on Storageβ
blob_v1andblob_piece_v1data is persisted on a node- The materialization logic differs from other documents, see the blob http specification to read more
Notes on Replicationβ
- Nodes can choose to ignore blobs when they exceed certain minimum or maximum length requirements or have unsupported mime types
- Nodes can choose to only replicate blob pieces when there is at least one relation to the blob itself from other documents