Pre-rendering and hosting
Pressline never stores image bytes. It hot-links your Preview and validates your Printfile by reading its header with one ranged GET, so:
- URLs are public and immutable. A Printfile URL for a (Design, Spec Hash) pair never changes content. Put files under a content-addressed key (the sample uses
printfiles/<designId>/<specHash>.png) in R2, Vercel Blob, S3 or your own disk; serveRangerequests if you can (Pressline reads at most 64 KiB, and expects a PNG’sIDATto start inside it). Use one dot in the last path segment (<specHash>.png, nevername..png): Printful’s upload refuses a two-dot filename. - Design IDs are unguessable: 8–128 characters of
[A-Za-z0-9_-], random. Anyone with the ID can see the Preview. - Pre-render on finalize. Fetch
GET /api/offersfrom the Pressline instance: every Offer and variant comes with its Printfile Spec. Render a Printfile per Spec while the Customer is still in your app and checkout never waits; a Spec you cannot render (aspect, budget) makes that Offer ineligible viaoffers. - Sync or 202. If a render takes longer than a request, answer
202 { retryAfterMs }and finish in the background; Pressline polls, and the Storefront tells the Customer to wait. Answering 200 synchronously is fine when rendering is fast. - Pressline verifies: exact size; 8-bit; non-interlaced; not palette-indexed; a declared color space that is not CMYK or grayscale; alpha per the Spec; a file under 200 MB;
specHashechoed,Content-Typeand size as declared. Anything else it can see but does not enforce it records as a Deviation and shows the Operator; a Deviation never blocks a sale.
The sample Engine does all of this in a few hundred lines.