remove() doesn't seem to remove the file from a bucket

I am running a script to delete files:
await supabase.storage
.from('myBucket')
.remove([`myBucket/${duplicateFile.name}`]); // includes bucket in pathname
await supabase.storage
.from('myBucket')
.remove([`myBucket/${duplicateFile.name}`]); // includes bucket in pathname
however, the file remains after. Things I have checked: - Policy: Only users who are authenticated & exist in a specific table of users is allowed: Policies under storage.buckets DELETE Enable delete for ADMIN users
((auth.role() = 'authenticated'::text) AND (EXISTS ( SELECT 1
FROM admin_users
WHERE (admin_users."userId" = auth.uid()))))
((auth.role() = 'authenticated'::text) AND (EXISTS ( SELECT 1
FROM admin_users
WHERE (admin_users."userId" = auth.uid()))))
- Checked My bucket settings:
[
{
"id": "myBucket",
"name": "myBucket",
"owner": null,
"created_at": "2024-01-25 15:08:19.641355+00",
"updated_at": "2024-01-25 15:08:19.641355+00",
"public": false,
"avif_autodetection": false,
"file_size_limit": null,
"allowed_mime_types": null,
"owner_id": null
}
]
[
{
"id": "myBucket",
"name": "myBucket",
"owner": null,
"created_at": "2024-01-25 15:08:19.641355+00",
"updated_at": "2024-01-25 15:08:19.641355+00",
"public": false,
"avif_autodetection": false,
"file_size_limit": null,
"allowed_mime_types": null,
"owner_id": null
}
]
- Errors: none exist. Any other ideas?
1 Reply
garyaustin
garyaustin2d ago
You need to meet both select and delete RLS. You need to meet select RLS on your admin table. Try simplifying the RLS if that does work. There will be no error.

Did you find this page helpful?