Delete Objects
Learn about deleting objects
When you delete one or more objects from a bucket, the files are permanently removed and not recoverable. You can delete a single object or multiple objects at once.
Deleting objects should always be done via the Storage API and NOT via a SQL query. Deleting objects via a SQL query will not remove the object from the bucket and will result in the object being orphaned.
Delete objects#
To delete one or more objects, use the remove method.
1import { createClient } from '@supabase/supabase-js'2const supabase = createClient('your_project_url', 'your_supabase_api_key')34// ---cut---5await supabase.storage.from('bucket').remove(['object-path-2', 'folder/avatar2.png'])When deleting objects, there is a limit of 1000 objects at a time using the remove method.
RLS#
To delete an object, the user must have the delete permission on the object. For example:
1create policy "User can delete their own objects"2on storage.objects3for delete4TO authenticated5USING (6 owner = (select auth.uid()::text)7);