diff --git a/example/next-storage/README.md b/example/next-storage/README.md index ea5762c9a..76b7ec127 100644 --- a/example/next-storage/README.md +++ b/example/next-storage/README.md @@ -31,4 +31,10 @@ begin; commit; alter publication supabase_realtime add table profiles; + +-- Set up Storage! +insert into storage.buckets (id, name) values ('avatars', 'avatars'); +create policy "Avatar images are publicly accessible." on storage.objects for select using (true); +create policy "Inserted avatar file name starts with the user's id." on storage.objects for insert with check (auth.uid()::text = substring(name, 1, 36)); +create policy "Updated avatar file name starts with the user's id." on storage.objects for update with check (auth.uid()::text = substring(name, 1, 36)); ``` diff --git a/example/next-storage/components/Account.tsx b/example/next-storage/components/Account.tsx index dd3aceac7..59a9cf622 100644 --- a/example/next-storage/components/Account.tsx +++ b/example/next-storage/components/Account.tsx @@ -42,7 +42,7 @@ export default function Account({ session }: { session: AuthSession }) { } let { error: updateError } = await supabase.from('profiles').upsert({ - id: user.id, + id: user!.id, avatar_url: filePath, }) @@ -73,7 +73,7 @@ export default function Account({ session }: { session: AuthSession }) { let { data, error } = await supabase .from('profiles') .select(`username, website, avatar_url`) - .eq('id', user.id) + .eq('id', user!.id) .single() if (error) { @@ -94,7 +94,7 @@ export default function Account({ session }: { session: AuthSession }) { const user = supabase.auth.user() const updates = { - id: user.id, + id: user!.id, username, website, updated_at: new Date(), diff --git a/example/next-storage/package.json b/example/next-storage/package.json index b5d0771e4..2374294d8 100644 --- a/example/next-storage/package.json +++ b/example/next-storage/package.json @@ -14,6 +14,7 @@ "react-dom": "17.0.1" }, "devDependencies": { - "@types/react": "^17.0.3" + "@types/react": "^17.0.3", + "typescript": "^4.2.3" } }