Skip to content

Storage

Thorben edited this page Nov 21, 2022 · 1 revision

avatar (Public)

In order to provide and save custom avatars uploaded by the users, create an public bucket called avatars and apply the following policies to storage.objects or directly to the bucket.

Policies

Select

CREATE POLICY "Enable read access for all users" ON "storage"."objects"
AS PERMISSIVE FOR SELECT
TO authenticated
USING (true)

Insert

CREATE POLICY "Enable insert for authenticated users only" ON "storage"."objects"
AS PERMISSIVE FOR INSERT
TO authenticated
WITH CHECK (true)

Update

CREATE POLICY "Enable update for users based on uid" ON "storage"."objects"
AS PERMISSIVE FOR UPDATE
TO authenticated
USING (auth.uid() = owner)
WITH CHECK (auth.uid() = owner)

Delete

CREATE POLICY "Enable delete for users based on user_id" ON "storage"."objects"
AS PERMISSIVE FOR DELETE
TO authenticated
USING (auth.uid() = owner)
Clone this wiki locally