Upload
@rockshin/tao-uiSelect, drop and manage files with real requests, custom uploads and controlled lists.
Choose from text, picture, picture-card and picture-circle lists. The examples below demonstrate local selection and explicitly simulated requests; connect action or customRequest to your own service for real uploads.
Examples
Click to select
Start with completed and failed files. New selections stay local because beforeUpload returns false.
Controlled file list
Own fileList through onChange; the clear button updates the same state.
Validate and ignore files
LIST_IGNORE excludes rejected files from the list. Browser accept is only a selection hint.
Multiple files and limits
maxCount caps the list length; one replaces the current file.
Drag and drop
Click anywhere in the drop zone or drop multiple files. Files stay local; no request is sent.
Picture list
A compact list with thumbnails, filenames and actions. Click a thumbnail to preview; new images stay local.
Picture wall with preview
Controlled picture-card list with completed, uploading and failed examples. Preview and remove images; the trigger hides at six files. Uploading progress is an initial display state, not a running request.
Circular picture list
The complete tile and its upload trigger are circular. Keyboard focus reveals the same actions as hover.
Avatar selection
Replace a single image without a file list. Validate image type and a 2 MB size limit before reading the local preview. This does not save an avatar to a server.
Custom request and progress
An explicit simulation with no network traffic: choose files to see progress, completion and cancellation. Enable the switch to simulate a failed request. Replace this customRequest with your transport in production.
Disabled upload
Disable selection and removal while keeping completed files available for preview.
Confirm removal
onRemove can reject removal synchronously or asynchronously. This example protects files with a switch.
Extra list information
Render per-file information and choose which list actions appear.
Phone selection and paste
pastable accepts clipboard files. The browser and device control available file sources.
API
Upload.Dragger
Inherits Upload props and adds height?: number for the drop zone, excluding the file list.
UploadFile
Requires uid and name. Common fields are status (uploading / done / error / removed), percent, url, thumbUrl, originFileObj, response, error, size and type. Files stopped by beforeUpload have no status.
ShowUploadListInterface
showPreviewIcon, showDownloadIcon and showRemoveIcon accept booleans or (file) => boolean. previewIcon, downloadIcon, removeIcon and extra accept ReactNode or (file) => ReactNode. Cards show preview and remove by default; download is opt-in.
Connect an upload service
The live examples use local selection or simulated requests. To send files to a server, set action to the upload endpoint and name to the multipart field the server expects.
If you supply customRequest, report progress with onProgress and finish each request once with onSuccess or onError. Return an object with an abort() method if your transport supports cancellation. With a controlled fileList, store the list from onChange to show the latest status for each file.
Since 0.0.49, Upload also handles failures while resolving action or data, and synchronous exceptions from customRequest. The affected file shows an error and the other files in the batch continue.