Skip to content

Instantly share code, notes, and snippets.

@dv
Created May 13, 2012 12:00
Show Gist options
  • Save dv/2688057 to your computer and use it in GitHub Desktop.
Save dv/2688057 to your computer and use it in GitHub Desktop.
Delete all files in a S3 bucket
#!/usr/bin/ruby
require 's3'
service = S3::Service.new(
:access_key_id => 'XXXXXXXX',
:secret_access_key => 'XXXXXXXX'
)
bucket = service.buckets.find('bucket-to-delete')
bucket.objects.each do |object|
puts "Deleting #{object.full_key}"
object.destroy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment