Sha256: fc4ba07858b63e30ac5929fda51a97751c7b3a9dada1befc00e585f2a528b24d

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module Heirloom

  class Uploader

    def initialize(args)
      @config = args[:config]
      @name = args[:name]
      @id = args[:id]
      @logger = @config.logger
    end

    def upload(args)
      heirloom_file = args[:file]
      bucket_prefix = args[:bucket_prefix]
      public_readable = args[:public_readable]

      @config.regions.each do |region|
        bucket = "#{bucket_prefix}-#{region}"

        s3_uploader = Uploader::S3.new :config => @config,
                                       :logger => @logger,
                                       :region => region

        s3_uploader.upload_file :bucket          => bucket,
                                :file            => heirloom_file,
                                :id              => @id,
                                :key_folder      => @name,
                                :key_name        => "#{@id}.tar.gz",
                                :name            => @name,
                                :public_readable => public_readable

        s3_uploader.add_endpoint_attributes :bucket     => bucket,
                                            :id         => @id,
                                            :name       => @name
      end
      @logger.info "Upload complete."
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.2.0 lib/heirloom/archive/uploader.rb