useStorageUploadWithProgress
useStorageUploadWithProgress(
bucket):object
Hook to upload a file to a bucket with built-in progress tracking
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
bucket | string |
Returns
Section titled “Returns”object
| Name | Type | Default value |
|---|---|---|
progress | UploadProgress | null | - |
reset() | () => void | - |
upload | UseMutationResult<{ fullPath: string; id: string; path: string; } | null, Error, { file: Blob | File | ArrayBuffer; options?: Omit<UploadOptions, "onUploadProgress">; path: string; }, unknown> | mutation |
Example
Section titled “Example”const { upload, progress, reset } = useStorageUploadWithProgress('avatars')
// Upload with automatic progress trackingupload.mutate({ path: 'user.jpg', file: file})
// Display progressconsole.log(progress) // { loaded: 1024, total: 2048, percentage: 50 }