Skip to content

Instantly share code, notes, and snippets.

View rajesh38's full-sized avatar

Rajesh Paul rajesh38

View GitHub Profile
@rajesh38
rajesh38 / delete_s3_files.rb
Created August 3, 2018 07:47
Delete objects from S3
# 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>/)}