Upload a file from the browser straight to a private AWS S3 bucket.
Version 1 · Files to AWS S3Designed, not builtModule 3 of 15
DesignUI ComponentsSections
UI Components Live gallery
What the Upload service ships for apps to use, as the package packages/ui-upload.
Each built component is shown live, from its package, in each of its states. Pick a state to see it; every state has its own stand-in for the service's API, with made-up data (CORE-V1-E0-19).
Components call only the Upload API, plus the storage link that API hands out. They never call another service.
An app can supply its own create and complete functions to wrap Upload in its own process (DocFlow does, to record the document as well). The components still know nothing about the app.
They ship as the package packages/ui-upload and work in any app.
Each component works on its own, given its inputs and a signed-in person. It may depend on Identity's login component and on nothing else from another service (Nikhil's decision on #36). Pages place components side by side and pass values between them.
No tokens in browser JavaScript: requests carry the HttpOnly session cookie and the gateway does the rest. Upload and download links are short-lived and fixed to one file.
Every action works without dragging: a phone uses the file picker or the camera.
Every request has a loading state that keeps the layout still, and a failure state with a plain-language message and a way to retry.
Keyboard reachable, visible focus, labelled controls, progress announced to screen readers, WCAG AA contrast, usable at 320 pixels wide, in light and dark mode.
UploadArea
Component
Where a person drops or picks a file; it checks the file, uploads it with progress, and reports the result.
Inputs
accept{mimes, maxBytes, maxPages}, optional
Limits to check in the browser and send to Upload. Default: the service's limits.
create, completefunctions, optional
Override the calls that create and confirm the file, for an app that wraps Upload. Default: Upload's own endpoints.
onUploaded(file) => void
Called with the ready file. The app decides what happens next.
cameraboolean, optional
Show a Take photo button on phones. Default true.
States
Idle: 'Drop a file here, or choose one', with Choose file and, on phones, Take photo
Dragging over: the area is highlighted
Refused in the browser: the reason (wrong type, too large) and the area stays ready
Uploading: the file name and an UploadProgress bar
Checking: 'Checking your file…'
Uploaded: 'Uploaded', then onUploaded is called
Rejected: the reason in plain words and Choose another file
Failed: the message for the error and Retry
Disabled: while the app does not allow another upload
Calls
POST /files
the storage link (PUT)
POST /files/{fileId}/complete
●LiveFrom the package, synthetic data
⇪
Drop a file here, or choose one
PDF, PNG or JPEG · up to 10 MB and 10 pages
useUpload()
Hook
The upload steps without any visuals, for an app that wants its own design: create, send with progress, confirm, and retry with a fresh link when one has expired.
Inputs
accept{mimes, maxBytes, maxPages}, optional
As for UploadArea.
create, completefunctions, optional
As for UploadArea.
States
idle
uploading with progress from 0 to 100
checking
ready with the file
rejected with the reason
failed with the error code
Calls
POST /files
the storage link (PUT)
POST /files/{fileId}/complete
●LiveFrom the package, synthetic data
{
"status": "idle"
}
UploadProgress
Component
A progress bar with the file name, the percentage, and Retry or Cancel.
Inputs
progressnumber 0 to 100
How far the upload is.
fileNamestring
Shown above the bar.
onRetry, onCancelfunctions, optional
Shown as buttons when given.
States
In progress (announced to screen readers every 25%)
Complete
Stopped, with Retry
Calls
None: it shows what useUpload reports.
●LiveFrom the package, synthetic data
invoice-nw-0187.pdf
Uploading and checking the file40%
FileList
Component
The signed-in person's files, newest first, with type, size, date and status, and actions to open or delete each.
Inputs
statusstring, optional
Show only files with this status.
pageSizenumber, optional
How many to load at a time. Default 20.
States
Loading: placeholder rows of the same height
Empty: 'No files yet.' and, if the app provides one, an upload button
Loaded, with Load more when there is a next page
Failed: 'Couldn't load your files.' and Retry
Calls
GET /files
●LiveFrom the package, synthetic data
OpenFileButton
Component
Opens a stored file in a new tab, or downloads it.
Inputs
fileIdstring
The file.
downloadboolean, optional
Download instead of opening. Default false.
States
Default
Working: disabled while the link is fetched
Failed: the message (still uploading, expired, not found) next to the button
Calls
GET /files/{fileId}/download-url
●LiveFrom the package, synthetic data
FilePreview
Component
Shows a stored PDF page by page, or an image, inside the page, so a person can read the document beside other information. New: decided on #36 and confirmed on PR #65, used on DocFlow's upload screen (`UPLOAD-V1-E2-04`) and extraction page (`EXTRACTION-V1-E3-04`), and by any other app.
Inputs
fileIdstring
The file.
pagenumber, optional
The page to show; changing it scrolls to that page. Default 1.
onPageChange(page) => void, optional
Called when the person moves to another page.
highlightstring, optional
Text to mark on the shown page, for example a field's source quote. Ignored if not found.
States
Loading: a placeholder of the document's shape
Shown: one page at a time with page number, previous and next, and zoom; an image fits the width
Link expired: fetches a new 5-minute link without a reload
Not available: 'This document is no longer available' when the file was deleted or expired after 30 days
Failed: the message and Retry
Calls
GET /files/{fileId}/download-url?disposition=inline
●LiveFrom the package, synthetic data
Northwind Paper Co. 12 Mill Lane, Springfield, 01234 billing@example.com