Reputation: 597
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
Upvotes: 0
Views: 783
Reputation: 1
So I had encountered an similar issue; And I found out that the file path was not being correctly matched. I was receiving the path URL with encoded characters like "Profile%20Picture" instead of actual path which was "Image Profile." So, this prevented the image from being deleted.
After using decodeURIComponent(your_extracted_path)
function, which decoded the encoded file path, the issue was resolved, and the image was successfully deleted from the bucket.
I hope this helps!
Upvotes: 0
Reputation: 18690
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.
Upvotes: 2