demarches-normaliennes/app/uploaders/attestation_uploader.rb

31 lines
662 B
Ruby
Raw Normal View History

2017-06-02 14:30:26 +02:00
class AttestationUploader < BaseUploader
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
unless Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
def filename
"attestation-#{secure_token}.pdf"
end
private
def secure_token
model.content_secure_token ||= SecureRandom.uuid
end
2017-06-02 14:30:26 +02:00
end