React Native · Components
FileUpload
File upload field: picks with the system picker (photo/video or file; no permission needed), validates by rules (type, size, count, duplicates), and uploads with progress when upload is given; failed uploads can be retried.
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Gallery: photos, full screen preview (←/→, swipe)
Images, Video · Up to 10 MB · Up to 8 files
Profile photo: a single image, Change button
PNG, JPEG, WEBP · Up to 2 MB
Edit form: files on the server and type icons
sozlesme-2026.pdf
471 KB
budget.xlsx
89.1 KB
presentation-october.pptx
5.2 MB
kaynak-code.zip
12 MB
Inline: in compact forms
Import
FileUpload
componentFile upload field: picks with the system picker (photo/video or file; no permission needed), validates by rules (type, size, count, duplicates), and uploads with progress when upload is given; failed uploads can be retried. Same names as FileUpload on web. The pickers come from the @yasinsensoy/native/file-system module.
Examples
FileSize
typeFile size: a number of bytes or text with a unit ("5 MB", "500KB", "1.5 GB"). Units are base 1024 (1 KB = 1024 bytes).
FileUploadStatus
typeUpload status (same as web).
FileUploadItem
interfaceA file in the list.
| Name | Type | Description |
|---|---|---|
id | string | Stable id. |
name | string | File name. |
size? | number | undefined | Bytes. |
type? | string | undefined | MIME type. |
uri? | string | undefined | Local address (file://, Android content://); absent for a server file. |
url? | string | undefined | Preview/download address (a file on the server). |
status? | FileUploadStatus | undefined | Upload status. |
progress? | number | undefined | Upload percentage (0–100). |
error? | string | undefined | Error message when the upload failed. |
value? | unknown | Return value of upload (e.g. the file id on the server). |
width? | number | undefined | Image/video width (pixels). |
height? | number | undefined | Image/video height (pixels). |
original? | MediaFile | undefined | Original file of an edited image/video (with edit). Re-editing starts from here; uri is the edited version. |
edits? | MediaEdits | undefined | Applied edits (with edit). |
FileUploadInit
typeInitial file: an id is generated if not given.
| Name | Type | Description |
|---|---|---|
name | string | File name. |
size? | number | undefined | Bytes. |
type? | string | undefined | MIME type. |
uri? | string | undefined | Local address (file://, Android content://); absent for a server file. |
url? | string | undefined | Preview/download address (a file on the server). |
status? | FileUploadStatus | undefined | Upload status. |
progress? | number | undefined | Upload percentage (0–100). |
error? | string | undefined | Error message when the upload failed. |
value? | unknown | Return value of upload (e.g. the file id on the server). |
width? | number | undefined | Image/video width (pixels). |
height? | number | undefined | Image/video height (pixels). |
original? | MediaFile | undefined | Original file of an edited image/video (with edit). Re-editing starts from here; uri is the edited version. |
edits? | MediaEdits | undefined | Applied edits (with edit). |
id? | string | undefined | Item id; generated if omitted. |
Rejection reason (same as web).
FileRejection
interfaceA rejected file.
| Name | Type | Description |
|---|---|---|
file | PickedFile | The rejected file. |
reason | FileRejectionReason | Why it was rejected. |
message | string | Message to show. |
FileUploadContext
interfaceValues passed to the upload function.
| Name | Type | Description |
|---|---|---|
signal | AbortSignal | Cancelled when the file is removed or the component unmounts. Pass it to FileSystem.upload. |
onProgress | (progress: number | { fraction: number | null; }) => void | Progress: 0–100 or a FileSystem.upload onProgress result. |
FileUploadSource
typeWhere to pick from.
FileUploadProps
interfaceProps of FileUpload.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
layout? | "list" | "gallery" | "list" | list: rows; gallery: square thumbnails. |
multiple? | boolean | false | Multiple files. |
accept? | string | readonly string[] | Accepted types: "image/*", ".pdf", ["image/png", "application/pdf"]. | |
maxSize? | FileSize | Maximum size (5_000_000 or "5 MB"). | |
minSize? | FileSize | Minimum size. | |
maxFiles? | number | Maximum files (with multiple). | |
validate? | (file: PickedFile) => string | null | undefined | false | Extra validation: return an error message, or nothing if valid. | |
value? | readonly FileUploadInit[] | Files (controlled). | |
defaultValue? | readonly FileUploadInit[] | Initial files (e.g. the ones on the server). | |
onValueChange? | (items: FileUploadItem[]) => void | When the list changes. | |
onReject? | (rejections: FileRejection[]) => void | Files that break the rules (the message also shows below the field). | |
upload? | (file: FileUploadItem, context: FileUploadContext) => Promise<unknown> | Upload when picked. The returned value becomes the item's value; if it throws the item is marked as failed and can be retried. | |
uploadConcurrency? | number | 3 | Maximum concurrent uploads. |
source? | FileUploadSource | "auto" | Picker: media the photo/video picker, document the file picker, auto media if accept is only images/videos, otherwise files. |
edit? | boolean | FileUploadEditOptions | Edit images and videos with MediaEditor (crop, rotate, filters, drawing, trimming video). true enables all tools; for details see FileUploadEditOptions. The size rule is applied after editing. | |
pick? | (options: { multiple: boolean; accept: string[]; }) => Promise<PickedFile[]> | Your own picker (e.g. a camera); when given source is ignored. | |
placeholder? | ReactNode | Button text. | |
hint? | ReactNode | Hint below the button; generated from the size/count limits if omitted. | |
icon? | IconProp | "upload" | Button icon. |
onItemPress? | (item: FileUploadItem) => void | When a file is tapped (for preview, e.g. FileSystem.open). | |
readOnly? | boolean | Read-only: no adding/removing. | |
style? | StyleProp<ViewStyle> | Style of the root view. |