class S3Poller::Downloader
Public Class Methods
new(local_path)
click to toggle source
# File lib/s3poller/downloader.rb, line 5 def initialize(local_path) @local_path = local_path end
Public Instance Methods
download(file)
click to toggle source
# File lib/s3poller/downloader.rb, line 9 def download(file) begin $log.info("Downloading: #{file.key}") local_file_path = "#{@local_path}#{file.key}" dirname = File.dirname(local_file_path) FileUtils.mkdir_p(dirname) File.open(local_file_path, 'w') do |local_file| local_file.write(file.body) end rescue Exception => e $log.error("Failed to download file #{file.key}, #{e.message}") end end