Sha256: ef25c72e22e64b0624e053ebfdfce40df6c93f2dbac20a6d5b672f711f1ef9c4
Contents?: true
Size: 1.27 KB
Versions: 5
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Decidim # This class deals with uploading files to Decidim. It is intended to just # hold the uploads configuration, so you should inherit from this class and # then tweak any configuration you need. class ApplicationUploader < CarrierWave::Uploader::Base process :validate_inside_organization # 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 default_path = "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" return File.join(Decidim.base_uploads_path, default_path) if Decidim.base_uploads_path.present? default_path end def skip_ssrf_protection?(_uri) true end protected # Validates that the associated model is always within an organization in # order to pass the organization specific settings for the file upload # checks (e.g. file extension, mime type, etc.). def validate_inside_organization return if model.is_a?(Decidim::Organization) return if model.respond_to?(:organization) && model.organization.is_a?(Decidim::Organization) raise CarrierWave::IntegrityError, I18n.t("carrierwave.errors.not_inside_organization") end end end
Version data entries
5 entries across 5 versions & 1 rubygems