The File Upload recipe provides a runnable example folder demonstrating a complete upload flow: file selection via file-dropzone.tsx, upload progress tracking, client-side validation, an uploaded asset list, and a signed-URL handoff pattern for secure server-side uploads. The recipe ships with stories, unit tests, and copy-pasteable code that developers can adapt for their applications.
Goals
Demonstrate a complete upload flow using the existing file-dropzone.tsx component.
Show upload progress tracking with cancel support.
Include client-side validation (file type, size, count limits).
Provide an uploaded asset list with preview, remove, and retry actions.
Document the signed-URL handoff pattern for secure uploads to cloud storage.
Ship as a runnable example folder with stories and tests.
Non-Goals
Building a new file-upload component (uses existing file-dropzone.tsx).
Implementing a real backend or cloud storage integration.
Providing image editing, cropping, or annotation.
Building a file manager or document management system.
Server-side virus scanning or content moderation.
Scope
In Scope
Area
Description
Recipe folder
Self-contained example folder with source, stories, and tests
File selection
Integration with file-dropzone.tsx for drag-and-drop and click-to-select
Upload progress
Progress bar per file with percentage and cancel button
Client-side validation
File type allowlist, max file size, max file count
Validation error display
Inline errors per file; rejected files listed with reasons
Uploaded asset list
List of completed uploads with preview thumbnail, filename, size, and actions
Remove action
Remove a file from the upload list (before or after upload)
Retry action
Retry a failed upload
Signed-URL handoff
Documented pattern for requesting a signed URL from the server, uploading directly to storage
Stories
Storybook stories demonstrating each state
Unit tests
Tests covering validation, progress, and asset list behavior
Out of Scope
Area
Reason
New file-upload primitive
Uses existing file-dropzone.tsx
Real backend/cloud storage
Recipe uses mock upload functions
Image editing/cropping
Separate concern
Chunked/resumable uploads
Advanced feature deferred to future iteration
Server-side validation
Consumer responsibility
Users and Pain Points
User Groups
User
Description
Needs
Application developers
Engineers building file upload features
A complete reference implementation they can copy and customize
QA engineers
Testers verifying upload flows
Stories showing all upload states for visual testing
New team members
Engineers learning design system patterns
A working example with tests showing best practices
Pain Points
User
Pain Point
Impact
Application developers
file-dropzone.tsx exists but there is no example showing the complete upload flow
Developers build incomplete flows; miss progress tracking, validation, or error handling
Application developers
No documented pattern for signed-URL uploads
Each team invents its own server handoff pattern
Application developers
Upload state management (pending, uploading, complete, failed) is built from scratch each time
Duplicated, inconsistent implementations
Definitions
Term
Definition
Recipe
A runnable example folder with source code, stories, and tests that developers copy and adapt
Signed URL
A time-limited, pre-authenticated URL that allows direct upload to cloud storage without exposing credentials
Upload progress
A per-file percentage (0-100) indicating upload completion
Validation
Client-side checks on file type, size, and count before upload begins
Asset list
A UI list showing uploaded files with preview, metadata, and actions
Current State
Existing Behavior
file-dropzone.tsx provides a drag-and-drop file selection area with configurable accept types and multiple file support. It handles file selection events but does not manage uploads, progress, validation, or asset display.
Current Limitations
No upload progress tracking pattern.
No client-side validation example (type, size, count).
No uploaded asset list component or pattern.
No signed-URL handoff documentation.
No runnable example tying the flow together.
Existing Workarounds
Developers build upload flows from scratch using file-dropzone.tsx as the starting point.
Progress tracking is often omitted or implemented with varying quality.
Signed-URL patterns are passed via tribal knowledge.
Proposed Solution
Summary
Create a recipe folder (src/recipes/file-upload/) containing a composed upload flow, a mock upload function with progress simulation, client-side validation logic, an uploaded asset list, and documentation for the signed-URL handoff pattern. Ship with Storybook stories and Vitest unit tests.
Key Capabilities
FileUploadDemo component composing FileDropzone, progress indicators, validation, and asset list.
validateFiles(files, config) function checking type, size, and count constraints.
UploadedAssetList component showing completed uploads with preview, metadata, and actions.
mockUpload(file) function simulating progress and completion for stories and tests.
Signed-URL handoff pattern documented in the recipe MDX page.
User Experience
Developers browse the recipe in Storybook, see the upload flow in action via stories, and copy the code into their application. They replace mockUpload with their real upload function (including signed-URL request) and customize the validation config.
Developer Experience
The recipe is a self-contained folder. Developers copy it, wire up their backend, and have a working upload flow. The useFileUpload hook encapsulates state management. Validation is configurable via a typed config object.
Requirements
ID
Requirement
Priority
Notes
FR-001
The recipe must integrate with file-dropzone.tsx
Must
Existing component
FR-002
The recipe must show upload progress per file
Must
Progress bar with percentage
FR-003
The recipe must include client-side validation
Must
Type, size, count
FR-004
The recipe must show an uploaded asset list
Must
Preview, filename, size, actions
FR-005
The recipe must document the signed-URL handoff pattern
Must
MDX documentation
FR-006
The recipe must ship with stories
Must
Visual reference
FR-007
The recipe must ship with unit tests
Must
Quality gate
FR-008
The recipe should support cancel during upload
Should
UX improvement
FR-009
The recipe should support retry on failed uploads
Should
Error recovery
Priority Definitions
Priority
Meaning
Must
Required for this feature to ship.
Should
Important, but can be deferred if needed.
Could
Nice to have. Not required for initial release.
Functional Requirements
ID
Requirement
User Benefit
Priority
FUNC-001
useFileUpload hook accepts a config with accept, maxSizeMB, maxFiles