In my case, when users upload an image to S3 through Carrierwave (using fog) – their original image is processed and optimized copies are made and stored in S3 as well. However, when users delete these images – Carrierwave removes only the original, and the directory + optimized copies remain. I'd like to find a way to delete the original file, it's directory, and all files within.
I've found the following in Carrierwave's source, that I'm thinking might become helpful:
# File lib/carrierwave/storage/s3.rb, line 100
def delete
AWS::S3::S3Object.delete @path, @uploader.s3_bucket
end
I'm wondering if anyone has accomplished something like this? I'd love to hear how you've done it... this could save quite a bit of disk in the long run.