React noob
07/21/2022, 5:00 PMsql
select * from storage.buckets.id = "hiking-picture"::text
``Failed to validate sql query: syntax error at or near "="``garyaustin
07/21/2022, 6:31 PMVinzent
07/21/2022, 7:19 PMwhere
garyaustin
07/21/2022, 7:23 PMselect * from storage.buckets where id = 'hiking-picture'
works without ::text but does not hurt to add it.garyaustin
07/21/2022, 7:33 PMReact noob
07/21/2022, 9:00 PMsql
create policy insert_as_admin ON storage.buckets.id = 'hiking-picture'::text for all using (
(EXISTS ( SELECT 1
FROM profiles
WHERE ((profiles.admin IS TRUE) AND (profiles.id = 'bi215-8e02-6c3f13e05026'::uuid))))
);`
do not pass workgaryaustin
07/21/2022, 9:13 PMgaryaustin
07/21/2022, 9:13 PMReact noob
07/21/2022, 9:13 PMsql
create policy insert_as_admin ON storage.buckets WHERE id = 'hiking-picture' for all using(
exists(select 1 from profiles WHERE profiles.admin is true)
)
React noob
07/21/2022, 9:14 PMgaryaustin
07/21/2022, 9:14 PMReact noob
07/21/2022, 9:14 PMgaryaustin
07/21/2022, 9:15 PMReact noob
07/21/2022, 9:18 PMReact noob
07/21/2022, 9:19 PMgaryaustin
07/21/2022, 9:19 PMcreate policy "Restricted Access"
on storage.objects for all
using (
bucket_id = 'hiking-picture'
and auth.role() = 'authenticated'
);
You would then modify the and to be your exists part.garyaustin
07/21/2022, 9:20 PMgaryaustin
07/21/2022, 9:20 PMReact noob
07/21/2022, 9:22 PMgaryaustin
07/21/2022, 9:24 PMgaryaustin
07/21/2022, 9:28 PMgaryaustin
07/21/2022, 9:29 PMReact noob
07/21/2022, 9:30 PM