Module: Kontrast::ImageUploader

Included in:
ApiEndpointRunner, PageRunner
Defined in:
lib/kontrast/image_uploader.rb

Instance Method Summary collapse

Instance Method Details

#upload_images(test) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/kontrast/image_uploader.rb', line 3

def upload_images(test)
    worker_pool = Workers::Pool.new
    worker_pool.resize(Kontrast.configuration.workers_pool_size)

    Workers.map(Dir.entries("#{Kontrast.path}/#{test}"), pool: worker_pool) do |file|
        next if ['.', '..'].include?(file)
        Kontrast.fog.directories.get(Kontrast.configuration.aws_bucket).files.create(
            key: "#{Kontrast.configuration.remote_path}/#{test}/#{file}",
            body: File.open("#{Kontrast.path}/#{test}/#{file}"),
            public: true
        )
    end
end