about summary refs log blame commit diff
path: root/app/controllers/concerns/obfuscate_filename.rb
blob: 22736ec3abf968bbb07c5cb19b1e346a51e44981 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                             
 


                               


                                
 

                                                                                           
     
# frozen_string_literal: true

module ObfuscateFilename
  extend ActiveSupport::Concern

  class_methods do
    def obfuscate_filename(path)
      before_action do
        file = params.dig(*path)
        next if file.nil?

        file.original_filename = SecureRandom.hex(8) + File.extname(file.original_filename)
      end
    end
  end
end