2017-10-30 16:07:02 +01:00
|
|
|
class CommentaireFileUploader < BaseUploader
|
|
|
|
def root
|
2018-03-06 13:44:29 +01:00
|
|
|
Rails.root.join("public")
|
2017-10-30 16:07:02 +01:00
|
|
|
end
|
|
|
|
|
2018-04-18 12:24:37 +02:00
|
|
|
if Flipflop.remote_storage?
|
2017-10-30 16:07:02 +01:00
|
|
|
storage :fog
|
|
|
|
else
|
|
|
|
storage :file
|
|
|
|
end
|
|
|
|
|
|
|
|
def store_dir
|
|
|
|
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
|
|
|
end
|
2017-10-31 16:21:26 +01:00
|
|
|
|
2019-05-07 13:20:20 +02:00
|
|
|
def extension_whitelist
|
2018-10-01 13:55:12 +02:00
|
|
|
['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp', 'jpg', 'jpeg', 'png', 'zip', 'txt']
|
2017-10-31 16:21:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def accept_extension_list
|
2019-05-07 13:20:20 +02:00
|
|
|
extension_whitelist.map { |e| ".#{e}" }.join(",")
|
2017-10-31 16:21:26 +01:00
|
|
|
end
|
2017-10-30 16:07:02 +01:00
|
|
|
end
|