You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
344 B

  1. # frozen_string_literal: true
  2. module ObfuscateFilename
  3. extend ActiveSupport::Concern
  4. class_methods do
  5. def obfuscate_filename(path)
  6. before_action do
  7. file = params.dig(*path)
  8. next if file.nil?
  9. file.original_filename = SecureRandom.hex(8) + File.extname(file.original_filename)
  10. end
  11. end
  12. end
  13. end