My Storage Structure:
my-bucket/
- dir_1/
- file_1
- dir_A
- dir_2/
What I tried:
default_storage.exists(name='dir_2/')
o/p: True
default_storage.delete(name='dir_2/')
dir_2
got deleted successfully.
But when I try the same for dir_1
:
default_storage.exists(name='dir_1/')
o/p: False
default_storage.delete(name='dir_1/')
This doesn't work. dir_1 still exists
How to delete dir_1 completely using the default_storage
?
I used bash scripts to delete the folders and then called the scripts from Django. You could obviously use powershell scripts or vbscript if you were on windows.
I realise your question involves default_storage but this is a work around. The other option would be looping through the directories and deleting the files individually and then deleting the empty folder.