/ Cases / Creative agency / System

A delivery portal and galleries for a creative agency

Password-protected galleries with expiration dates, on-the-fly ZIP downloads, automatic thumbnails and a team with change history.

/ AINUR/ 2026.09/ Own storage on Cloudflare R2

0

copies for the ZIP

1

own domain

/ The problem

Delivering heavy photos and videos to clients depended on third-party services with limits and someone else's branding.

/ What we built

  • Public galleries with a password and an expiration date.
  • ZIP downloads generated on the fly, with no stored copies.
  • Automatic thumbnails and a team with change history.

/ How it works

  1. 01Upload to R2
  2. 02Password-protected gallery
  3. 03Client reviews
  4. 04ZIP download

/ Real code

index.mjsjs
  if (match[2] === "zip") {
    // …
    const { readable, writable } = new TransformStream();
    const writer = writable.getWriter();
    context.waitUntil(
      pumpZip(bucket, items.map((item) => ({ key: item.key, name: item.name, size: item.size })), writer, share.createdAt || Date.now())
        .catch((error) => writer.abort(error).catch(() => {})),
    );
    return new Response(readable, {
      headers: {
        "content-type": "application/zip",
        // …
      },
    });
  }
// …
async function pumpZip(bucket, entries, writer, stampMs) {
  // …
    const object = await bucket.get(entry.key);
    if (object) {
      const reader = object.body.getReader();
      while (true) {
        const { done, value } = await reader.read();
        if (done) break;
        crc = crcUpdate(crc, value);
        written += value.length;
        await write(value);
      }

■ The ZIP is streamed from R2 while it downloads: no copy is stored and it handles multi-GB folders.

/ Stack

Cloudflare R2Cloudflare WorkersCloudflare Images