summaryrefslogtreecommitdiff
path: root/app/services/infrastructure/temporary_storage.rb
blob: 5ce8db49ec46fedc14144cf26259924a2c2879be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class TemporaryStorage
  def store(file)
    "#{tmp_dir}/#{file.original_filename}".tap do |new_path|
      FileUtils.mv(file.path, new_path)
    end
  end

  private

  def tmp_dir
    Rails.root.join("tmp/uploads/#{SecureRandom.uuid}").tap do |directory|
      system "mkdir -p #{directory}"
    end
  end
end