Franck
05/07/2022, 4:02 AMjs
const { data, error } = await supabase.storage.createBucket(`${userId}-bucket`)
Where userId
comes from useAuth()
hook from Clerk.
Although I'm getting the following error on POST:
json
{
error: ""
message: "invalid input syntax for type uuid: \"user_28YHvhguBwY5edeBlB6WrD0pKNE\""
statusCode: "22P02"
}
The payload looks like this:
json
id: "user_28YHvhguBwY5edeBlB6WrD0pKNE-bucket"
name: "user_28YHvhguBwY5edeBlB6WrD0pKNE-bucket"
public: false
Is it a RLS error?Needle
05/07/2022, 4:02 AMgaryaustin
05/07/2022, 4:04 AMNeedle
05/07/2022, 4:04 AMFranck
05/07/2022, 4:07 AMgaryaustin
05/07/2022, 4:08 AMFranck
05/07/2022, 4:36 AMjs
const { data, error } = await supabase
.storage
.from('users') .upload(`${userId}/${file.path}`, file, {
cacheControl: '3600',
upsert: false
})
But still getting the same error...
I think it's because of this
https://github.com/supabase/supabase/discussions/4954
I'm not super confident writing RLS Policies,
how could I turn the template provided above to something similar to this example?
sql
CREATE POLICY "Authenticated users can update their own todos"
ON public.todos FOR UPDATE USING (
auth.role() = 'authenticated'::text
) WITH CHECK (
requesting_user_id() = user_id
);
garyaustin
05/07/2022, 4:43 AMFranck
05/07/2022, 4:45 AMFranck
05/07/2022, 5:57 AMsql
bucket_id = 'users' AND requesting_user_id() = (storage.foldername(name))[1]
where requesting_user_id() does:
sql
create or replace function requesting_user_id()
returns text
language sql stable
as $$
select nullif(current_setting('request.jwt.claims', true)::json->>'sub', '')::text;
$$;
But still the same error...Franck
05/07/2022, 8:08 AMstorage.foldername(name)[1]
is supposed to return?garyaustin
05/07/2022, 1:44 PMFranck
05/11/2022, 6:43 AMerror: ""
message: "invalid input syntax for type uuid: \"user_28oxcIJAoJ8A07LMAaXIoZmdHO2\""
statusCode: "22P02"
triggered?Franck
05/17/2022, 10:04 AMgaryaustin
05/17/2022, 2:38 PMFranck
05/17/2022, 9:19 PMFranck
05/17/2022, 9:20 PM"search": "?columns=%22name%22%2C%22owner%22%2C%22bucket_id%22",