Sha256: 4cb186cb95356aee3d795545add0695b1b408907a3ae231bff7962eaf5e9372b

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

module ClickSession
  class S3FileUploader
    def initialize(s3_connection = S3Connection.new)
      @s3_connection = s3_connection
    end

    def upload_file(file_name)
      @s3_connection.upload_from_filesystem_to_bucket(
          file_name,
          file_path_for(file_name)
        )
      uploaded_file_path_for(file_name)
    end
    
    private
    def file_path_for(file_name)
      "#{Rails.root}/tmp/#{file_name}"
    end

    def uploaded_file_path_for(file_name)
      "https://s3.amazonaws.com/#{@s3_connection.bucket_name}/#{file_name}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
click_session-0.1.1 lib/click_session/s3_file_uploader.rb
click_session-0.1.0 lib/click_session/s3_file_uploader.rb
click_session-0.0.1 lib/click_session/s3_file_uploader.rb