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.
_10await supabase.storage.from('bucket').remove(['object-key-1', 'object-key-2'])
RLS
To delete an object, the user must have the delete
permission on the object. For example:
_10create policy "User can delete their own objects"_10on storage.objects_10for delete_10TO authenticated_10USING (_10 owner_id = (select auth.uid())_10);