Use original file extension for uploaded files

This commit is contained in:
Guillaume Lazzara 2016-05-24 17:34:52 +02:00
parent 2c7b65199e
commit a62076c34b
2 changed files with 4 additions and 4 deletions

View file

@ -31,9 +31,9 @@ class CerfaUploader < CarrierWave::Uploader::Base
def filename
if original_filename.present? || model.content_secure_token
if Features.remote_storage
filename = "#{model.class.to_s.underscore}-#{secure_token}.pdf"
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
else
filename = "#{model.class.to_s.underscore}.pdf"
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
end
end
filename

View file

@ -31,9 +31,9 @@ class PieceJustificativeUploader < CarrierWave::Uploader::Base
def filename
if original_filename.present? || model.content_secure_token
if Features.remote_storage
filename = "#{model.class.to_s.underscore}-#{secure_token}.pdf"
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
else original_filename
filename = "#{model.class.to_s.underscore}.pdf"
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
end
end
filename