storage icon indicating copy to clipboard operation
storage copied to clipboard

Cannot Delete image from bucket

Open ahmedabdelhafez opened this issue 3 years ago • 9 comments

Hello dears, i have 2 days trying to delete an image from the bucket 1- the bucket is private 2- the bucket name is => images 3- i try multiple things and all fails

here is my code used to delete the image:

deleteImage(bucked: string, imageId: string) { return this.supabaseConfig .getSupabaseClient() .storage.from(bucked) .remove([${imageId}]); }

ahmedabdelhafez avatar Feb 24 '22 22:02 ahmedabdelhafez

Are you using the anon key or service key here @ahmedabdelhafez? if you are using the anon key, you may need to allow access by adding the right RLS policies in your dashboard

inian avatar Feb 25 '22 05:02 inian

Are you using the anon key or service key here @ahmedabdelhafez? if you are using the anon key, you may need to allow access by adding the right RLS policies in your dashboard

Hello @inian I am using the example in the docs, the problem also it give me ok that the item is deleted but when move to the supabase storage I found that the image is not deleted

ahmedabdelhafez avatar Feb 25 '22 10:02 ahmedabdelhafez

Can you share a reproducible example? If you don't want to share the exact code here, feel free to send us a support ticket with the project ref, key and the code you are using at https://app.supabase.io/support/new

Thanks!

inian avatar Feb 26 '22 04:02 inian

Can you share a reproducible example? If you don't want to share the exact code here, feel free to send us a support ticket with the project ref, key and the code you are using at https://app.supabase.io/support/new

Thanks!

hello @inian here is the code example i put the code in the service and pass parameters to the function deleteImage(bucket: string, imageId: string) { return this.supabaseConfig .getSupabaseClient() .storage.from(bucket) .remove([${imageId}]); }

ahmedabdelhafez avatar Feb 26 '22 18:02 ahmedabdelhafez

and also i want to say that the bucket is private and i can upload image to it but the download and delete i cannot do this step why i don't know

ahmedabdelhafez avatar Feb 26 '22 19:02 ahmedabdelhafez

Are you using the anon key or service key here? if you are using the anon key, can you share the current RLS policies you have on the storage schema?

Might be easier to debug if you share the url you are trying to access / delete

inian avatar Feb 27 '22 03:02 inian

Are you using the anon key or service key here? if you are using the anon key, can you share the current RLS policies you have on the storage schema?

Might be easier to debug if you share the url you are trying to access / delete

here is all policies granted to the bucket image

ahmedabdelhafez avatar Feb 27 '22 08:02 ahmedabdelhafez

I have the same problem, is there any solution for this problem?

vab1997 avatar Aug 13 '22 03:08 vab1997

Hello @ahmedabdelhafez and @vab1997 we would need to see the RLS you created for the DELETE operation. Feel free to paste it here, we can help you to debug further

fenos avatar Sep 26 '22 13:09 fenos

Feel free to re-open when providing more details

fenos avatar Dec 15 '22 09:12 fenos