storage
Skill1 starsChanged 3 months agoMITView on GitHub
File upload and blob storage for a Next.js 16 site — dropzone UX with drag-drop as enhancement over a real file input, true progress from XHR upload events, instant client validation of type and size, zod v4 re-validation on the server, Vercel Blob as the default store with S3-compatible (S3/R2) as the alternative, server-generated storage keys, and post-upload rendering through next/image with persisted dimensions. Invoke during the backend phase when the brief needs avatars, user images, attachments, or any file upload, when choosing between server-relay and client-direct upload paths, or when uploaded images cause layout shift or bypass the image pipeline. Trigger phrases — "upload a file", "image upload", "avatar", "drag and drop", "file storage", "Vercel Blob", "S3 bucket", "attachments", "the upload shows no progress".
6 other projects use a version of this.
Adopted by
Most recently taken up by
- frankxai/Starlight-Intelligence-Systemtheir own version, first seen Sep 6, 2026
- butterbase-ai/butterbase-skillstheir own version, first seen Jun 10, 2026
- moasq/ios-dev-agenttheir own version, first seen May 26, 2026
- beriberikix/zephyr-agent-skillstheir own version, first seen May 18, 2026
- lightpointventures/claude-code-startertheir own version, first seen Mar 27, 2026
- ajshedivy/ibmi-agent-skillstheir own version, first seen Mar 15, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- butterbase-ai/butterbase-skills★ 533same name
- beriberikix/zephyr-agent-skills★ 68same name
- lightpointventures/claude-code-starter★ 36same name
- frankxai/Starlight-Intelligence-System★ 10same name
- ajshedivy/ibmi-agent-skills★ 4same name
- moasq/ios-dev-agent★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository79 other files it gives its agents.
- ultrawebSkill
- analyticsSkill
- animejsSkill
- api-designSkill
- app-structureSkill
- assetsSkill
- authSkill
- award-canonSkill
- briefSkill
- buttonsSkill
- cardsSkill
- cartSkill
- checkpointSkill
- colorSkill
- command-paletteSkill
- component-apiSkill
- consentSkill
- content-cmsSkill
- copywritingSkill
- databaseSkill
- data-displaySkill
- data-fetchingSkill
- depthSkill
- directionSkill
- emailSkill
- faqSkill
- feature-sectionsSkill
- footerSkill
- formsSkill
- gate-accessibilitySkill
- gate-antislopSkill
- gate-codeSkill
- gate-contentSkill
- gate-performanceSkill
- gate-responsiveSkill
- gate-visualSkill
- handoffSkill
- heroSkill
- hidden-craftSkill
- i18nSkill
- iconsSkill
- identitySkill
- imagerySkill
- iterateSkill
- layout-gridSkill
- marginaliaSkill
- media-optimizationSkill
- micro-interactionsSkill
- mockupSkill
- motion-languageSkill
- navigationSkill
- overlaysSkill
- page-transitionsSkill
- paymentsSkill
- physicsSkill
- previewSkill
- pricingSkill
- print-craftSkill
- product-detailSkill
- retrofitSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Every upload surface designs all six states: idle, drag-over, uploading with a real percentage, success with preview, error with retry, …
- Distinctive: line 15
Every stored image renders through next/image with dimensions persisted at upload time — zero CLS from user content.
- Very specific: line 20
Read design/BRIEF.md: what gets uploaded, by whom, how big.
- Very specific: line 24
Verify empirically: upload a valid file, an oversized file, and a wrong-type file renamed to .png — the last two must fail with designed …
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
storage — uploads that earn trust
Stage: Phase 7 — Backend - Reads: design/BRIEF.md, design/SYSTEM.md (§color, §motion for dropzone states) - Writes: components/upload/*, upload route handler or actions, lib/storage.ts, next.config.ts images.remotePatterns
Standard
- Client validation is instant: type and size rejected before a single byte leaves the browser. The server re-validates everything — the client is UX, never security.
- Every upload surface designs all six states: idle, drag-over, uploading with a real percentage, success with preview, error with retry, disabled. A spinner with no percent is not progress.
- Storage keys are server-generated; the user's filename is display metadata, never a path.
- Every stored image renders through next/image with dimensions persisted at upload time — zero CLS from user content.
- Drag-drop is an enhancement over a real
<input type="file">— the keyboard path is the input, always.
Process
- Read design/BRIEF.md: what gets uploaded, by whom, how big. Pick server-relay vs client-direct and the store (below).
- Build the authorizing surface first: auth check, zod schema, scoped token/presign or receiving action.
- Build the dropzone per Upload UX — the input first, drag-drop and progress layered on.
- Persist the file record with the blob write; wire rendering through next/image +
remotePatterns. - Verify empirically: upload a valid file, an oversized file, and a wrong-type file renamed to
.png— the last two must fail with designed errors on BOTH client and server paths; confirm the rendered image lands with zero CLS.
Choose the path
Two architectures, picked by file size and hosting:
- Server relay — file posts to a route handler or server action; the server writes to the store. Simplest wiring, but the file transits your function and serverless platforms cap request bodies (Vercel functions ~4.5 MB — verify the current limit before relying on it). Right for avatars and small documents.
- Client-direct — the browser uploads straight to storage; your server only authenticates and issues a scoped token or presigned URL pinning allowed type, max size, and key prefix. No body cap, no double transfer, real progress. Default for anything beyond tiny files.
Store choice:
- Vercel Blob — the default on this stack: zero infra, public/private access, a built-in client-direct token flow. Exact SDK surface (put/upload/token handler) — verify against current docs first.
- S3-compatible (AWS S3, Cloudflare R2) — when hosting off Vercel, files run large, or egress cost matters; presigned-PUT URLs give the same client-direct shape.
- Either way: the authorizing endpoint checks auth BEFORE issuing anything, and the token constrains content type, size, and prefix — an unscoped upload token is an open bucket.
Upload UX
- Dropzone = styled
<label>around the real input (sr-only, notdisplay:none— it must stay focusable);focus-visiblering from the token palette viafocus-within; drag-over shifts border to accent and background one neutral step in 150–250ms — no scale jumps, no bounce. - Real progress requires
XMLHttpRequest—xhr.upload.onprogressgives loaded/total;fetchcannot report upload progress. Render a determinate bar + percent text; mirror toaria-live="polite"at coarse steps (25/50/75/done), not every tick. - Validate before the network: extension AND MIME allowlist, size cap with an honest message ("Max 4 MB — this file is 12.8 MB"), image preview via
URL.createObjectURL(revoke it after). - Multiple files: one row per file with independent progress, error, retry, and remove — one bad file never fails the batch.
- Errors land beside the dropzone, tied via
aria-describedby; retry keeps the file selected.
Server validation — zod v4
// the token-issuing handler (client-direct) or the receiving action (server relay)
import { z } from 'zod'
const uploadMeta = z.object({
type: z.enum(['image/jpeg', 'image/png', 'image/webp'], { error: 'JPEG, PNG, or WebP only' }),
size: z.number().int().positive().max(4 * 1024 * 1024, { error: 'Max 4 MB' }),
name: z.string().max(200), // display only — never a storage path
})- Key shape:
${prefix}/${crypto.randomUUID()}.${extFromValidatedMime}— extension derived from the validated MIME, never fromname(path traversal, collisions). - Re-serving user files publicly: sniff magic bytes rather than trusting the declared content-type — a renamed
.html"image" served inline is stored XSS. - Persist the record alongside the blob write (per
database): url, width, height, alt, size, owner. Read image dimensions server-side at write time so rendering never guesses. - Content images require alt text at upload; decorative ones store
alt: ''explicitly.
After upload — next/image
// next.config.ts
images: { remotePatterns: [{ protocol: 'https', hostname: '<your-store-host>' }] }- Render with stored dimensions:
<Image src={url} width={width} height={height} alt={alt} sizes="(min-width: 768px) 33vw, 100vw" />— orfill+sizesinside a sized container. - LCP-critical uploaded images (cover, profile hero) get
preload—priorityis deprecated in Next 16. placeholder="blur"on remote images needs a storedblurDataURL— generate the tiny base64 at upload time or omit the prop; a plain token-colored background beats a broken blur.- Optimistic preview: show the local object URL immediately while uploading, swap to the stored URL on success, snap back with a visible error on failure — never silently.
Anti-patterns
accept="image/*"as the only validation — it filters the picker dialog, nothing else.put(file.nameor any storage key built from the user's filename — greppable; traversal and collisions.setIntervaldriving a progress bar — fake progress; wirexhr.upload.onprogressor show indeterminate honestly.<img src=for stored images — bypasses the next/image pipeline: no sizing, no format negotiation, CLS.priorityon next/image — deprecated in 16; usepreload.- Size cap only on the client — the server schema is the real cap.
fs.writeFileintopublic/at runtime — serverless filesystems are ephemeral; files vanish on the next deploy.- An
onClickdropzonedivwith no<input type="file">— keyboard and screen-reader users locked out. - Submit with no pending state — double submits create orphaned blobs.
Worked example — Loop & Thread, customer review photos as social proof
Moved to references/example.md — read only when this build's case is genuinely ambiguous; the sections above are the decision material.
Composes with
Moved to references/composes.md — the handoff map; load it when orchestrating this skill against its neighbors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

