Sha256: 2010a59e770012d97dbe42c78fd2d3fc928810a2c3ccfce5afd15ebe534e3282

Contents?: true

Size: 634 Bytes

Versions: 4

Compression:

Stored size: 634 Bytes

Contents

module Jackie
  class AWSUploader
    def initialize(connection_params, access_params)
      load_dependency
      AWS::S3::Base.establish_connection!(connection_params)
      @config = access_params
    end

    def upload(file)
      AWS::S3::S3Object.store(file, open(file), @config[:bucket])
      AWS::S3::S3Object.url_for(file, @config[:bucket])
    end

    private
    def load_dependency
      begin
        require "aws/s3"
      rescue LoadError => e
        $stderr.puts "You don't have aws/s3 installed in your application. Please add it to your Gemfile and run bundle install"
        raise e
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jackie-0.1.2 lib/jackie/aws_uploader.rb
jackie-0.1.1 lib/jackie/aws_uploader.rb
jackie-0.1.0 lib/jackie/aws_uploader.rb
jackie-0.0.3 lib/jackie/aws_uploader.rb