Methods
public class
public instance
Public class methods
new
(access_key=nil, secret_key=nil, region=nil, debug=nil)
[show source]
# File lib/rudy/aws/s3.rb, line 5 5: def initialize(access_key=nil, secret_key=nil, region=nil, debug=nil) 6: require 'aws/s3' 7: 8: url ||= 'http://sdb.amazonaws.com' 9: # There is a bug with passing :server to EC2::Base.new so 10: # we'll use the environment variable for now. 11: #if region && Rudy::AWS.valid_region?(region) 12: # "#{region}.sdb.amazonaws.com" 13: #end 14: 15: @access_key_id = access_key || ENV['AWS_ACCESS_KEY'] || ENV['AMAZON_ACCESS_KEY_ID'] 16: @secret_access_key = secret_key || ENV['AWS_SECRET_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY'] 17: @base_url = url 18: @debug = debug || StringIO.new 19: 20: 21: AWS::S3::Base.establish_connection!( 22: :access_key_id => @access_key_id, 23: :secret_access_key => @secret_access_key 24: ) 25: 26: end
Public instance methods
bucket_exists?
(name)
def store(path, bucket)
fname = File.basename(path) S3Object.store(fname, open(path), bucket)
end
[show source]
# File lib/rudy/aws/s3.rb, line 56 56: def bucket_exists?(name) 57: b = find_bucket(name) 58: !b.nil? 59: end
create_bucket
(name, location=nil)
[show source]
# File lib/rudy/aws/s3.rb, line 32 32: def create_bucket(name, location=nil) 33: opts = {} 34: opts[:location] = location.to_s.upcase if location 35: ::AWS::S3::Bucket.create(name, opts) 36: end
destroy_bucket
(name)
[show source]
# File lib/rudy/aws/s3.rb, line 38 38: def destroy_bucket(name) 39: ::AWS::S3::Bucket.delete(name) 40: end
find_bucket
(name)
[show source]
# File lib/rudy/aws/s3.rb, line 42 42: def find_bucket(name) 43: blist = ::AWS::S3::Service.buckets 44: blist.select { |bobj| bobj.name == name }.first 45: end
list_bucket_objects
(name)
[show source]
# File lib/rudy/aws/s3.rb, line 47 47: def list_bucket_objects(name) 48: ::AWS::S3::Bucket.objects(name) 49: end
list_buckets
()
[show source]
# File lib/rudy/aws/s3.rb, line 28 28: def list_buckets 29: ::AWS::S3::Service.buckets 30: end