function AvatarUpload() {
const { upload, progress, isUploading } = useUpload('storage_files');
const handleFile = async (e) => {
const file = e.target.files[0];
const { error } = await upload(file, {
operation: 'upload',
file_path: `avatars/${userId}.jpg`
});
if (!error) toast.success('Uploaded!');
};
return (
<div>
<input type="file" onChange={handleFile} disabled={isUploading} />
{isUploading && <ProgressBar value={progress} />}
</div>
);
}
Hook for uploading files via Smart Upload (signed URLs, direct to R2).