Module: Kilt::Upload::Local

Defined in:
lib/kilt/upload/local.rb

Class Method Summary collapse

Class Method Details

.upload(type, file_reference) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/kilt/upload/local.rb', line 4

def self.upload type, file_reference
  Kilt::Utils.ensure_local_storage_dir_exists
  if file_reference
    File.open(Rails.root.join('public', 'uploads', type, file_reference.original_filename), 'wb') do |file|
      file.write(file_reference.read)
    end
    file_reference.original_filename
  else
    ''
  end
end