Search code examples
supabase

Not able to remove object from supabase storage


I'm using supabase client.

const { data, error }  = await supabase.storage
    .from('main')
    .remove([input.imageId])

imageId is the correct path. When I test it with getting the object like this:

const { data: fileExistsData } = supabase.storage
            .from('main')
            .getPublicUrl(input.imageId);

I get the object successfully, but when I try to remove it the error and data look like this:

Error:  null
Data:  []

I tried to have my objects in the folder as well to see if it would help but same issue persists. I do have a basic DELETE permission set: (bucket_id = 'main'::text) And also for storage.objects using expression true


Solution

  • You need select policy as well as the delete policy in order to delete the files in your bucket even if your bucket is a public bucket.