useStorageUpload
useStorageUpload(
bucket):UseMutationResult<{fullPath:string;id:string;path:string; } |null,Error, {file:Blob|File|ArrayBuffer;options?:UploadOptions;path:string; },unknown>
Hook to upload a file to a bucket
Note: You can track upload progress by passing an onUploadProgress callback in the options:
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
bucket | string |
Returns
Section titled “Returns”UseMutationResult<{ fullPath: string; id: string; path: string; } | null, Error, { file: Blob | File | ArrayBuffer; options?: UploadOptions; path: string; }, unknown>
Example
Section titled “Example”const upload = useStorageUpload('avatars')
upload.mutate({ path: 'user.jpg', file: file, options: { onUploadProgress: (progress) => { console.log(`${progress.percentage}% uploaded`) } }})For automatic progress state management, use useStorageUploadWithProgress instead.