Question1
I want to have a behaviour when user deletes a record so media/ images associated with this record are also delete (removed from storage). So Ive added this function to my stack for DELETE endpoint:
But When I downloaded backup of my storage I've learned that when I delete original file with path "/vault/path/....jpg" it will only delete the original but will keep all folders with different sizes:
What is the best practice to delete all associated files/folders when deleting a record and how to clean storage of unused files?
Question 2
In order to clean storage of files that associated with deleted records I run function stack to GET list of all files using Metadata API then filter those not associated with existing records.
Then I can delete it. But looks like only original files will be deleted not the folders with all size variations, right?
Please help, it is not clear in documentation how to keep storage clean.