Created
August 3, 2018 07:47
-
-
Save rajesh38/e0d7d1c272108a6539fc6397ee131ee2 to your computer and use it in GitHub Desktop.
Delete objects from S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using Aws::S3 rubygem | |
Aws.config.update({ | |
credentials: Aws::Credentials.new(Rails.application.secrets.s3_access_key, Rails.application.secrets.s3_secret_key) | |
}) | |
s3 = Aws::S3::Resource.new(region: '<region>') | |
s3.bucket('<bucket_name>').objects.each{|object| object.delete if (object.key !~ /<pattern_not_to_match>/)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment