I am trying the storage service from this @ supaba...
# help
b
I am trying the storage service from this @ supabase / supabase-js library. I am doing everything as per the documentation but still cannot save the new Bucket. I do not know why. Maybe I'm doing something wrong. Any hint is appreciated.
Copy code
js
const { createClient } = require('@supabase/supabase-js');
const { SUPABASE_KEY, SUPABASE_URL } = process.env;

const bucket = async () => {
  const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
  const { data, error } = await supabase.storage.createBucket('avatar');
  console.log(data);
  console.log(error);
};

bucket();

=================
this is the answer from the bucket function
null
{
  message: 'new row violates row-level security policy for table "buckets"',
  status: 400
}
n
Hello @Bartek! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
If your Supabase_KEY is anon key then you would need to have a storage policy set up to allow bucket inserts. https://supabase.com/docs/reference/javascript/storage-createbucket#notes. That probably is not very safe, so if you are calling this from a server you probably want your service role key.
n
Bartek (2022-04-02)
g
Also please don't double post in multiple areas.