Side project

Image & File Server

An upload and image server shared by several services. Browsers upload directly with a signed, short-lived grant; the server names files, bakes WebP widths, and issues signed read URLs for private buckets.

Period
2026.02 — 2026.06
Role
Plan · Design · Build · Ship · Improve · solo
Stack
Node.js, Express 5, multer, sharp, Docker, nginx

Process

  1. Plan

    Five services uploaded five different ways; set out to make it one.

  2. Design

    Wrote the protocol first: signed upload grants, server-side naming, private buckets.

  3. Build

    Express and sharp server plus a conformance checker every client must pass.

  4. Ship

    A merge to main is the release: a pull-based deployer rebuilds only the changed service, and clients must pass a 42-check conformance suite.

  5. Improve

    Ran an abuse test, then added a queue, quotas, and burst blocking; patched image-library CVEs.

System diagram 7 components · 6 connections Play the flow and trace each connection

Overview

An Express server that stores files in buckets and serves resized derivatives. A web store, a habit app, a B2B SaaS, and a music client all speak the same protocol.

Why I built it

When uploads went through a serverless function, its 4.5MB body limit capped every file: 4MB returned 200, 5MB returned 413, and the shrunk copy became the only copy.

Five services had five dialects—three file-naming rules, one with different read and write buckets, others handing the browser a token that could write or delete in any bucket. A protocol document became the single reference, with a conformance checker.

System

Service-to-service calls use an API key header; several keys are accepted at once so rotation needs no downtime.

Browser uploads use a stateless HMAC-SHA256 grant, valid 10 minutes, bound to one bucket, filename, size, and content type, upload-only. Private buckets use per-bucket keys and app-signed read URLs valid up to an hour. Secrets compare in constant time.

See this in the system diagram

Architecture and data

Buckets live on local disk with a derivative cache beside them. Widths 640, 828, 1280, 1920, and 2560 are pre-baked as WebP q80; the largest edge is 4096px.

The server names every file. Korean filenames had been read as latin1 and could not be fetched back. There is no dedupe by hash: if two products shared one file, deleting one would delete the other’s image.

Protection

30MB public and 100MB private limits. Buckets default to a 20GB quota, re-measured every 60 seconds. The pre-bake queue runs one at a time with at most 32 waiting.

Bursts of identical uploads are refused with 429. The fingerprint hashes the first 256KB plus size—about 0.1ms instead of 11ms for the full file. Daily backups go to a separate physical disk.

Stack

Node.js 22, Express 5, multer 2, sharp 0.35, Docker, nginx.

Notes

Hard parts: an abuse test pushed 46 uploads per second through with no limit, and pre-baking multiplied each upload into four resizes—40 uploads made 160 derivatives in 1.2 seconds on four cores. A documentation error on srcset shrank in-article images from 592px to 310px; the rule now never promises a width above the original.

What held: 42 of 42 conformance checks pass, upload bytes never pass through a web process, and the image stack was upgraded to clear libvips/libheif CVEs.