Skip to content

Commit 8749488

Browse files
authored
Merge pull request #140 from dshukertjr/master
Added storage policies to readme.md of next-storage example app
2 parents 5fc7362 + ee1eeb2 commit 8749488

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
@@ -48,7 +48,7 @@ export default function Account({
4848
}
4949

5050
let { error: updateError } = await supabase.from('profiles').upsert({
51-
id: user.id,
51+
id: user!.id,
5252
avatar_url: filePath,
5353
})
5454

@@ -79,7 +79,7 @@ export default function Account({
7979
let { data, error } = await supabase
8080
.from('profiles')
8181
.select(`username, website, avatar_url`)
82-
.eq('id', user.id)
82+
.eq('id', user!.id)
8383
.single()
8484

8585
if (error) {
@@ -100,7 +100,7 @@ export default function Account({
100100
const user = supabase.auth.user()
101101

102102
const updates = {
103-
id: user.id,
103+
id: user!.id,
104104
username,
105105
website,
106106
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)