2017-10-19 15:07:18 +02:00
|
|
|
class AttestationTemplateSignatureUploader < BaseUploader
|
2017-06-08 14:16:48 +02:00
|
|
|
def root
|
|
|
|
File.join(Rails.root, 'public')
|
|
|
|
end
|
|
|
|
|
|
|
|
# Choose what kind of storage to use for this uploader:
|
|
|
|
if Features.remote_storage
|
|
|
|
storage :fog
|
|
|
|
else
|
|
|
|
storage :file
|
|
|
|
end
|
|
|
|
|
|
|
|
# Override the directory where uploaded files will be stored.
|
|
|
|
# This is a sensible default for uploaders that are meant to be mounted:
|
|
|
|
def store_dir
|
2018-01-11 19:04:39 +01:00
|
|
|
if !Features.remote_storage
|
2017-06-08 14:16:48 +02:00
|
|
|
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Add a white list of extensions which are allowed to be uploaded.
|
|
|
|
# For images you might use something like this:
|
|
|
|
def extension_white_list
|
|
|
|
%w(jpg jpeg png)
|
|
|
|
end
|
2017-10-19 15:07:18 +02:00
|
|
|
|
|
|
|
def filename
|
|
|
|
if file.present?
|
|
|
|
"attestation-template-signature-#{secure_token}.#{file.extension.downcase}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def secure_token
|
|
|
|
model.signature_secure_token ||= SecureRandom.uuid
|
|
|
|
end
|
2017-06-08 14:16:48 +02:00
|
|
|
end
|