From ee1eeb2567720b5cd7cdbf8ffd4a7cee309d9bb2 Mon Sep 17 00:00:00 2001 From: dshukertjr <18113850+dshukertjr@users.noreply.github.com> Date: Sat, 27 Mar 2021 09:57:37 +0900 Subject: [PATCH] Added storage policies to readme.md of next-storage example app --- example/next-storage/README.md | 6 ++++++ example/next-storage/components/Account.tsx | 6 +++--- example/next-storage/package.json | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) 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" } }