class Stax::Aws::S3

Public Class Methods

bucket_region(bucket) click to toggle source
# File lib/stax/aws/s3.rb, line 27
def bucket_region(bucket)
  client.get_bucket_location(bucket: bucket).location_constraint
end
bucket_tags(bucket) click to toggle source
# File lib/stax/aws/s3.rb, line 17
def bucket_tags(bucket)
  client.get_bucket_tagging(bucket: bucket).tag_set
rescue ::Aws::Errors::NoSuchEndpointError
  warn("socket error for #{bucket}, retrying")
  sleep 1
  retry
rescue ::Aws::S3::Errors::NoSuchTagSet
  []
end
client() click to toggle source
# File lib/stax/aws/s3.rb, line 9
def client
  @_client ||= ::Aws::S3::Client.new
end
get_lifecycle(bucket) click to toggle source
# File lib/stax/aws/s3.rb, line 41
def get_lifecycle(bucket)
  client.get_bucket_lifecycle_configuration(bucket: bucket).rules
end
list_buckets() click to toggle source
# File lib/stax/aws/s3.rb, line 13
def list_buckets
  client.list_buckets.buckets
end
location(bucket) click to toggle source

get region, return us-east-1 if empty

# File lib/stax/aws/s3.rb, line 32
def location(bucket)
  l = client.get_bucket_location(bucket: bucket).location_constraint
  l.empty? ? 'us-east-1' : l
end
put(opt) click to toggle source
# File lib/stax/aws/s3.rb, line 37
def put(opt)
  client.put_object(opt)
end
put_lifecycle(bucket, cfg) click to toggle source
# File lib/stax/aws/s3.rb, line 45
def put_lifecycle(bucket, cfg)
  client.put_bucket_lifecycle_configuration(bucket: bucket, lifecycle_configuration: cfg)
end