1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/uploaders/project_cao_uploader.rb

34 lines
942 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# CarrierWave uploader for project CAO attachments.
# This file defines the parameters for these uploads
2015-05-05 03:10:25 +02:00
class ProjectCaoUploader < CarrierWave::Uploader::Base
include UploadHelper
include ContentTypeValidationFromFileContent
2015-05-05 03:10:25 +02:00
# Choose what kind of storage to use for this uploader:
storage :file
after :remove, :delete_empty_dirs
# 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
"#{base_store_dir}/#{model.id}"
end
def base_store_dir
"uploads/#{model.class.to_s.underscore}"
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
Setting.get('allowed_cad_extensions').split(' ')
2015-05-05 03:10:25 +02:00
end
def content_type_whitelist
Setting.get('allowed_cad_mime_types').split(' ')
end
2015-05-05 03:10:25 +02:00
end