not able to upload files to supabase storage bucket. this is the policy i have
((bucket_id = 'templates'::text) AND (storage.extension(name) = 'md'::text) AND (auth.role() = 'anon'::text))
when i try to upload files from dashboard, i get internal server error
27 Replies
Are you sure the policy is the issue? The dashboard should ignore the policy AND if bad policy you would get an RLS error. Check your storage and Postgres logs. Is this hosted or selfhosted/local?
its on dashboard
i dont think its dashboard issue
i mean i dont think its policy issue
i remove the policy
i set the bucket to public
it should have let me upload
Public does not allow uploads without meeting RLS policy. But the Dashboard storage UI should ignore it.

That is not an RLS policy error. Something is wrong.
i tried to check logs. i dont see anything
can you try creating a test storage bucket and see if you can upload
Internal server error should show an error in Storage or Postgres logs.
Are you hosted?
what do you mean hosted?
Are you using the Supabase online dashboard with their hosting or are you doing local dev or self hosting?
online dashboard with their hosting
Please check the Postgres logs again.
No issues public or not for bucket.


no errors
from logs
oh i see an error
null value in column "created_by" of relation "documents" violates not-null constraint
this constraint i meant to apply on different bucket
You have triggers on storage.objects?
yes
That can be very tricky.
You can't just trigger on insert or update alone.
This points out some of the issues....
GitHub
Trigger on insert, update and delete of storage objects · supabase ...
I could not find way to add trigger on storage objects.
im trying see the trigger from dashboard for storage schea
schema
but not able to

yes how do you see the code for the trigger on dashboard
create trigger on_file_upload
after insert on storage.objects
for each row
execute procedure private.handle_storage_update();
You can't. Supabase does not let you generate code for triggers on their schemas. You have to use SQL editor. This is because most of the time you really need to know what you are doing and like last month the way they trigger changed.
how do i add bucket name here
You can't just do an insert trigger see my link.
There are two inserts for a file upload and probably a delete if the file can't be stored to s3 after the first one.
thats okay.
i do not care about number of times it gets invoked
i just want it to trigger only on specific bucket
https://www.postgresql.org/docs/current/sql-createtrigger.html
You would need to add a WHEN condition to check the bucket name column = 'name'.
PostgreSQL Documentation
CREATE TRIGGER
CREATE TRIGGER CREATE TRIGGER — define a new trigger Synopsis CREATE [ OR REPLACE ] [ CONSTRAINT ] TRIGGER name …
thank you so much.
i fixed it by checking the bucket id in the function
>IF NEW.bucket_id <> 'my_bucket_name' THEN
RETURN NEW; -- Exit the function if the bucket ID does not match
END IF;