From 24b4ba6854d4efd04021d0156f5bb1675dacb010 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Tue, 31 Jan 2023 19:09:42 +1100 Subject: [PATCH] Generate filename --- app/commands/media/upload.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/commands/media/upload.rb b/app/commands/media/upload.rb index 2bf63b8..f117dd9 100644 --- a/app/commands/media/upload.rb +++ b/app/commands/media/upload.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "securerandom" + module Adamantium module Commands module Media @@ -9,7 +11,7 @@ module Adamantium def call(file:) pathname = Time.now.strftime("%m-%Y") - filename = file[:filename].split("/").last + filename = "#{SecureRandom.uuid}#{File.extname(file[:filename])}" dirname = File.join("public", "media", pathname)