Remove the entire content of a folder in storage #4218
-
Hello, is it possible to delete the folder or entire content of a folder using storage.remove()? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 21 replies
-
No. You can empty a bucket with a call or use the UI. |
Beta Was this translation helpful? Give feedback.
-
The UI can also delete complete folders... so do they also iterate through the files and then delete the folder itself? |
Beta Was this translation helpful? Give feedback.
-
Problem with the solution from above are folders inside folders. Supabase doesn't provide a way for recursive listing as far as I know so we have to implement it manually, right? |
Beta Was this translation helpful? Give feedback.
No. You can empty a bucket with a call or use the UI.
Otherwise you have to build up a list of file paths from the "folder" and remove them in a loop or as an array. I'm not sure how well that would work for large amount of files in a single call with an array, or looping in a database function. You probably need to run such code in a cloud function or on your server if you have one.
The new studio open source likely has examples of deleting all files in a folder as the user interface does that for you.