master
 1class TemporaryStorage
 2  def store(file)
 3    "#{tmp_dir}/#{File.basename(file.path).parameterize}".tap do |new_path|
 4      Rails.logger.debug("Copying... #{file.path} to #{new_path}")
 5      FileUtils.cp(file.path, new_path)
 6    end
 7  end
 8
 9  private
10
11  def tmp_dir
12    Rails.root.join("tmp/uploads/#{SecureRandom.uuid}").tap do |directory|
13      system "mkdir -p #{directory}"
14    end
15  end
16end