diff options
author | Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> | 2017-05-30 01:14:16 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-29 18:14:16 +0200 |
commit | 922fb74197ef65e6f6ebfba627f80eb483486c1c (patch) | |
tree | 6e32a01ea86a7eed35479e3632ebea7fdb13b892 /app/controllers | |
parent | 7bf2d6cb06570d84d96bbd2517da8b5e50d33309 (diff) |
Remove methods from ObfuscateFilename and spec (#3347)
* Remove methods from ObfuscateFilename * Spec ObfuscateFilename
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/obfuscate_filename.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/app/controllers/concerns/obfuscate_filename.rb b/app/controllers/concerns/obfuscate_filename.rb index 9c896fb09..22736ec3a 100644 --- a/app/controllers/concerns/obfuscate_filename.rb +++ b/app/controllers/concerns/obfuscate_filename.rb @@ -4,19 +4,13 @@ module ObfuscateFilename extend ActiveSupport::Concern class_methods do - def obfuscate_filename(*args) - before_action { obfuscate_filename(*args) } - end - end - - def obfuscate_filename(path) - file = params.dig(*path) - return if file.nil? + def obfuscate_filename(path) + before_action do + file = params.dig(*path) + next if file.nil? - file.original_filename = secure_token + File.extname(file.original_filename) - end - - def secure_token(length = 16) - SecureRandom.hex(length / 2) + file.original_filename = SecureRandom.hex(8) + File.extname(file.original_filename) + end + end end end |