Sha256: 3649aa5444c43549aaf17cb6047753f900a0594ca7fc8f8bf42789ffea63a60e

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

module Bubbles
  module Uploaders
    class S3
      extend Forwardable
      include Bubbles::CommonUploaderInterface

      def call
        File.open(uid_file, 'rb') do |file|
          s3.put_object(bucket: s3_bucket, key: s3_full_path, body: file)
        end
      rescue => e
        config.logger.error("#{e.message}")
        command_queue.reschedule(self)
      end

      def inspect
        "<##{self.class.name} uid_file: #{uid_file} to: s3://#{s3_bucket}#{s3_full_path}>"
      end

      private
        def_delegators :config, :s3_bucket, :s3_path, :s3_credentials, :s3_region
        def_delegators :bfile, :uid_file, :uid_file_name

        def s3
          @s3 ||= Aws::S3::Client.new({
            region: s3_region,
            credentials: s3_credentials
          })
        end

        def s3_full_path
          Pathname.new(s3_path).join(uid_file_name).to_s
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bubbles-0.0.2 lib/bubbles/uploaders/s3.rb
bubbles-0.0.1 lib/bubbles/uploaders/s3.rb