Sha256: 245aa672879950641439eb55b0b091114ee87b8c3d3fd3500081afc953b6d348

Contents?: true

Size: 924 Bytes

Versions: 14

Compression:

Stored size: 924 Bytes

Contents

module RailsConnector

class S3Blob
  class << self

    def s3_objects
      @s3_objects ||= s3_api.buckets[bucket_name].objects
    end

    def s3_api
      AWS::S3.new(
        :access_key_id => access_key_id,
        :secret_access_key => secret_access_key
      )
    end

    def configure(spec)
      @spec = spec.symbolize_keys
    end

    def find(id, options)
      new(id)
    end

    private

    attr_reader :spec

    def bucket_name
      spec[:bucket_name]
    end

    def access_key_id
      spec[:access_key_id]
    end

    def secret_access_key
      spec[:secret_access_key]
    end

  end

  attr_reader :id

  def initialize(id)
    @id = id
  end

  def s3_object
    @s3_object = self.class.s3_objects[id]
  end

  def url
    s3_object.public_url.to_s
  end

  def content_type
    s3_object.content_type
  end

  def length
    s3_object.content_length
  end

end

end # module RailsConnector

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.0.beta.200.889.d503e42 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.883.f5f063b lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.884.4bd86e6 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.869.9609b39 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.856.8c0fec5 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.809.bdfa8c3 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.785.05d4af9 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.744.99f67fc lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.720.44fbabd lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.713.e5c3150 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.681.7c84f4a lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.663.ceecdee lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.650.7c93155 lib/rails_connector/s3_blob.rb
infopark_cloud_connector-6.8.0.beta.200.621.4c8e1b0 lib/rails_connector/s3_blob.rb