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
347 B

  1. module ObfuscateFilename
  2. extend ActiveSupport::Concern
  3. class_methods do
  4. def obfuscate_filename(*args)
  5. before_action { obfuscate_filename(*args) }
  6. end
  7. end
  8. def obfuscate_filename(path)
  9. file = params.dig(*path)
  10. return if file.nil?
  11. file.original_filename = "media" + File.extname(file.original_filename)
  12. end
  13. end