From fe7b0edb38465e7fe97ead029c99d95299beec2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Thu, 21 Sep 2017 11:12:10 +0200 Subject: [PATCH] Adjust filename obfuscation to be able to remove cached uploads --- app/models/document.rb | 5 +++-- app/models/image.rb | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/document.rb b/app/models/document.rb index 0bd41d673..ff19cf390 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -1,8 +1,9 @@ class Document < ActiveRecord::Base include DocumentsHelper include DocumentablesHelper - has_attached_file :attachment, path: ":rails_root/public/system/:class/:prefix/:style/:hash.:extension", - url: "/system/:class/:prefix/:style/:hash.:extension", + has_attached_file :attachment, url: "/system/:class/:prefix/:style/:hash.:extension", + hash_data: ":class/:style", + use_timestamp: false, hash_secret: Rails.application.secrets.secret_key_base attr_accessor :cached_attachment diff --git a/app/models/image.rb b/app/models/image.rb index 358453385..da305957e 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -8,8 +8,9 @@ class Image < ActiveRecord::Base ACCEPTED_CONTENT_TYPE = %w(image/jpeg image/jpg) has_attached_file :attachment, styles: { large: "x#{MIN_SIZE}", medium: "300x300#", thumb: "140x245#" }, - path: ":rails_root/public/system/:class/:prefix/:style/:hash.:extension", url: "/system/:class/:prefix/:style/:hash.:extension", + hash_data: ":class/:style", + use_timestamp: false, hash_secret: Rails.application.secrets.secret_key_base attr_accessor :cached_attachment