Sha256: 8f883871944c93e1370310777899d1a21e030cc7e757004362dfc52bf32e35fe

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 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, acl: config.s3_acl)
        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

1 entries across 1 versions & 1 rubygems

Version Path
bubbles-0.0.3 lib/bubbles/uploaders/s3.rb