Media / API

foldkit-media/cloudflare

The media server's services on Cloudflare: originals in R2, the Images binding as the transformer, and variants kept in R2 behind the Cache API. Each takes the binding it needs, so build them in serveFetch's layer from the request's environment.

Functions

admissionRateLimitAdmission through a Workers rate-limit binding ([[ratelimits]]), whose limit and period are its configuration. It answers yes or no, not when, so a refusal…
inspectorImagesThe Inspector through the Images binding: an original's size from info, which costs no transformation. It makes no thumbnail, since raw pixels are not…
keyValueStoreR2An R2 bucket as an Effect KeyValueStore, for anything that keeps bytes by key: variantsKeyValueStore, originalsKeyValueStore, or the application's own.…
originalsR2Originals in an R2 bucket, each under its content hash.
transformerImagesThe Images binding as the transformer. It scales down, never up, and names the format, so the variant is what its URL says. A spent allowance is…
uploadsR2Uploads into an R2 bucket, each under its content hash: what originalsR2 reads.
variantsR2Variants kept in R2 under prefix, so one made last month is not made, and billed, again: variantsKeyValueStore over keyValueStoreR2. With cache…