Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supabase bucket - new row violates row-level security policy for table "objects"

Tags:

supabase

I am having an issue with uploading avatars to my supabase bucket as its giving me "new row violates row-level security policy for table "objects"". I tried other StackOverflow solutions and nothing. Before trying to upload I log in using supabse so my user is authenticated yet its still not letting me upload. I added this policy in storage.objects:

(role() = 'authenticated'::text) and clicked the insert button. Does anyone know what I am doing wrong? I assume its something to do with the policies. Thanks

This is how I'm trying to upload my avatar:

try {
  const { data, error } = await supabase.storage
    .from("/public/avatars")
    .upload(`${values.email}.png`, values.avatar, {
      cacheControl: "3600",
      upsert: true,
    });
  if (error) throw error;
} catch (error) {
  console.log(error);
}
like image 840
Mat Avatar asked Sep 03 '25 03:09

Mat


1 Answers

add new policy and enjoy :)

Because upsert need DELETE and UPDATE

enter image description here

like image 69
Juan Silupú Maza Avatar answered Sep 05 '25 01:09

Juan Silupú Maza