Skip to content

Commit ee1eeb2

Browse files
committed
Added storage policies to readme.md of next-storage example app
1 parent 98d85cf commit ee1eeb2

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

example/next-storage/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ begin;
3131
commit;
3232

3333
alter publication supabase_realtime add table profiles;
34+
35+
-- Set up Storage!
36+
insert into storage.buckets (id, name) values ('avatars', 'avatars');
37+
create policy "Avatar images are publicly accessible." on storage.objects for select using (true);
38+
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));
39+
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));
3440
```

example/next-storage/components/Account.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function Account({ session }: { session: AuthSession }) {
4242
}
4343

4444
let { error: updateError } = await supabase.from('profiles').upsert({
45-
id: user.id,
45+
id: user!.id,
4646
avatar_url: filePath,
4747
})
4848

@@ -73,7 +73,7 @@ export default function Account({ session }: { session: AuthSession }) {
7373
let { data, error } = await supabase
7474
.from('profiles')
7575
.select(`username, website, avatar_url`)
76-
.eq('id', user.id)
76+
.eq('id', user!.id)
7777
.single()
7878

7979
if (error) {
@@ -94,7 +94,7 @@ export default function Account({ session }: { session: AuthSession }) {
9494
const user = supabase.auth.user()
9595

9696
const updates = {
97-
id: user.id,
97+
id: user!.id,
9898
username,
9999
website,
100100
updated_at: new Date(),

example/next-storage/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"react-dom": "17.0.1"
1515
},
1616
"devDependencies": {
17-
"@types/react": "^17.0.3"
17+
"@types/react": "^17.0.3",
18+
"typescript": "^4.2.3"
1819
}
1920
}

0 commit comments

Comments
 (0)