Sha256: f2f0a14f3d65366a539a95173ec1b452fa19e45f751a41c89fb8079a7ac7e722

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

# encoding: utf-8

require 'aws/s3'

module TBird
  class Transmitter
    def initialize
      @s3 = AWS::S3.new(access_key_id: Configuration.aws_key, secret_access_key: Configuration.aws_secret)
    end

    def transmit!(name, file, options = {})
      s3object = s3bucket.objects[name]
      s3object.write(file, default_options.merge(options))
      s3object.public_url(secure: true)
    end

    private

    def s3bucket
      @s3bucket ||= @s3.buckets[Configuration.aws_bucket]
    end

    def default_options
      { 
        acl: :public_read,
        content_type: 'binary/octet-stream',
        metadata: {}
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
t_bird-0.0.5 lib/t_bird/transmitter.rb
t_bird-0.0.4 lib/t_bird/transmitter.rb
t_bird-0.0.3 lib/t_bird/transmitter.rb