Sha256: 3cc3569730e9bd53eee0aa7290143e0dca20397a21947cd124689d227eac11d8

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

module S3
  # a client for dealing with a single bucket
  class NamedBucket < Client
    attr_accessor :bucket_name

    # TODO: check bucket exists before setting it
    # options available:
    # :public_contents => true: all items put into bucket are made public
    def initialize(aws_access_key, aws_secret_access_key, bucket_name, options={}, &block)
      super(aws_access_key, aws_secret_access_key)
      @bucket_name = bucket_name
      @client_headers.merge!(canned_acl_header('public-read')) if options[:public_contents]
      yield self if block_given?
    end

    def root
      list_bucket(@bucket_name)
    end

    def put_text(string, resource_key, headers={})
      super(string, @bucket_name, resource_key, headers)
    end

    def put_file(filename, resource_key=nil, headers={})
      super(filename, @bucket_name, resource_key, headers)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
s33r-0.1 lib/s33r/named_bucket.rb