Blobs
Content too large for a record goes in a blob, which the client seals and moves straight to and from S3 through URLs the
routes presign, so its bytes never pass through the app. WithBlobs turns the routes on for the collections it names.
Without it they answer 404 blobs_disabled and the app needs no bucket. GET / gives each collection with blobs its
maxBlobBytes, and null to the rest. The settings are under Configuration.
| Route | Answers |
|---|---|
POST /{collectionId}/{recordId}/blobs/{blobId} with {"size": n} |
A URL to PUT exactly n bytes to. Over MaxBlobBytes answers 413 blob_too_large |
GET /{collectionId}/{recordId}/blobs/{blobId} |
A URL to GET the blob from. A missing blob is the storage’s own 404 |
DELETE /{collectionId}/{recordId}/blobs/{blobId} |
204, whether the blob was there or not |
- Keys.
{KeyPrefix}{userId}/{collectionId}/{recordId}/{blobId}, the user id escaped as a URI component, so a record’s blobs share a prefix. - A tombstone deletes the record’s blobs, listing and deleting under its prefix after the tombstone is written. When that fails, the push still succeeds and the failure is logged: a blob left behind costs storage, not privacy.
- Signature Version 4, with the size signed. An upload URL signs
Content-Length, so S3 refuses an upload of any other size. The AWS SDK presigns with version 2 in us-east-1 unlessAWSConfigsS3.UseSignatureVersion4is set, soWithBlobssets it for the process. - The client. An
IAmazonS3the app has registered already is used. Otherwise one is made with the standard AWS credential chain, or for an S3-compatible endpoint whenServiceUrlis set.
The bucket
Section titled “The bucket”- CORS. Its rules must let the app’s origins
PUTandGET: the browser sends the blob straight to the bucket. - Permissions. The role that presigns needs
s3:PutObject,s3:GetObject,s3:DeleteObjectands3:ListBucketon the prefix. WithoutListBucket, S3 answers a missing blob with403rather than404. - A lifecycle rule can delete what a client uploaded and never pushed a record for, which the server can’t tell apart from a blob in use.
Other storage
Section titled “Other storage”Blobs can go elsewhere through an IConsealSyncBlobStore registered after WithBlobs, as long as it presigns. It makes an
upload URL signed for an exact size, a download URL, and deletes one blob or every blob of a record. Each blob is opaque
ciphertext, sealed by the client.