https://supabase.com/ logo
#help
Title
# help
k

Kasper

03/30/2022, 9:39 PM
Is the storage api supposed to work for local development? I'm getting an RLS policy error when I try to upload files
n

Needle

03/30/2022, 9:39 PM
Hello @Kasper! 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

garyaustin

03/31/2022, 12:03 AM
By local development are you are running supabase server yourself, or running code from localhost? Have you set up storage policies for objects in that bucket for insert?
n

Needle

03/31/2022, 12:03 AM
Kasper (2022-03-30)
k

Kasper

03/31/2022, 6:21 PM
I'm running the Supabase CLI, followed the Local Development guide so the local database should be the same as the remote
g

garyaustin

03/31/2022, 6:31 PM
Have you set up storage policies for objects?
k

Kasper

03/31/2022, 6:37 PM
Yes
I had storage policies set up before I followed that guide
g

garyaustin

03/31/2022, 6:48 PM
Not sure that applies.
k

Kasper

03/31/2022, 6:51 PM
It looks like it's for the other way around, when migrating a storage policy to the remote, but maybe it's the same culprit
So I guess I should be able to recreate the storage policies manually
g

garyaustin

03/31/2022, 6:54 PM
Sorry, but I just have not messed with it. I know it is a "fake" storage system locally (not s3) but not clear on policies. No one had responded to you so was trying to get you somewhere, but afraid I might confuse things if I push more. If you narrow down you might ask again as doubt others will drift in to this "older" thread...
k

Kasper

03/31/2022, 6:55 PM
Yea I see, thank you for taking the time to respond :)
I'll see if it's possible to just recreate the policies
Alright, I tried just creating them with SQL queries, and I got the error
function uid() does not exist
Tried just renaming those to
auth.uid()
and the query is successful, but still getting policy errors
g

garyaustin

03/31/2022, 7:25 PM
Try set to just true to see if that works.
k

Kasper

03/31/2022, 7:25 PM
Will try that
Do you know if there's a way to just list the RLS policies?
g

garyaustin

03/31/2022, 7:28 PM
Local Studio does not have a storage section yet, I believe correct? I can see policies from my datagrip database tool on tables, I don't know the sql off hand to get them. pgadmin supposedly can lisi them.
k

Kasper

03/31/2022, 8:03 PM
I tried just disabling RLS for the
storage.objects
table, so now the issue is that the bucket doesn't exist
Copy code
Error uploading "2/0-jntnrrdl.png": insert or update on table "objects" violates foreign key constraint "objects_bucketId_fkey"
I guess I can create it from the JS api
g

garyaustin

03/31/2022, 8:10 PM
Well.... In looking at createBucket code it only appears to create the entry in the bucket table in storage schema. Does not make a call to actual storage. So If I read it correctly you can just create a row in the storage table.... https://github.com/supabase/storage-api/blob/master/src/routes/bucket/createBucket.ts
k

Kasper

03/31/2022, 8:13 PM
Alright, so you could safely just create the row in the
storage.buckets
table
I used the API already, and that did work 🎉
g

garyaustin

03/31/2022, 8:14 PM
Even better.
k

Kasper

03/31/2022, 8:14 PM
Request to
http://localhost:54321/storage/v1/bucket
body:
Copy code
{
  "id": "bucket-name",
  "name": "bucket-name",
  "public": true
}
RLS still not working unfortunately, but at least it's possible to use the storage
g

garyaustin

03/31/2022, 8:16 PM
The name bucket is somewhat misleading, as there really are no individual buckets in the s3 sense in Supabase. They have many users in the same s3 bucket.
k

Kasper

03/31/2022, 8:17 PM
Including in production as well?
Ah so it's more like a re-implementation of buckets inside a bucket
g

garyaustin

03/31/2022, 8:18 PM
There is no s3 at all in local, just simulated. Everything in the actual storage system is just objects with paths (the Supabase bucket is just part of the path in the actual storage. But it makes it easier for policies like public to have the bucket table.
k

Kasper

03/31/2022, 8:19 PM
Yeah, that makes sense
Thank you for helping out! :D
g

garyaustin

03/31/2022, 8:20 PM
All that and did not solve the original problem, but at least steps forward...
k

Kasper

03/31/2022, 8:23 PM
Yeah, better than nothing