Sha256: 8cf4fb3a7efdc84885b216fc68fa517ef4d11e6c316e7815cbaae41d4476ae7d

Contents?: true

Size: 579 Bytes

Versions: 2

Compression:

Stored size: 579 Bytes

Contents

module Awspec::Type
  class S3 < Base
    attr_reader :client, :bucket

    def initialize(id)
      super
      @client = Aws::S3::Client.new
      res = @client.list_buckets
      ret = @client.list_buckets[:buckets].find do |bucket|
        bucket.name == id
      end
      @id = id if ret
      @bucket = ret
    end

    def has_object?(key)
      res = @client.head_object({
                                  bucket: @id,
                                  key: key.sub(%r(\A/), '')
                                })
      res
      rescue
        false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
awspec-0.1.1 lib/awspec/type/s3.rb
awspec-0.1.0 lib/awspec/type/s3.rb