Sha256: e23d358c15f7ba6cf4df8b91c5ac19cf380a09eac8424894c0f8be14ed0a4cd7

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module CarrierWave
  module Uploader
    module Url
      extend ActiveSupport::Concern
      include CarrierWave::Uploader::Configuration
      include CarrierWave::Utilities::Uri

      ##
      # === Parameters
      #
      # [Hash] optional, the query params (only AWS)
      #
      # === Returns
      #
      # [String] the location where this file is accessible via a url
      #
      def url(options = {})
        if file.respond_to?(:url)
          tmp_url = file.method(:url).arity.zero? ? file.url : file.url(options)
          return tmp_url if tmp_url.present?
        end

        if file.respond_to?(:path)
          path = encode_path(file.path.sub(File.expand_path(root), ''))

          if host = asset_host
            if host.respond_to? :call
              "#{host.call(file)}#{path}"
            else
              "#{host}#{path}"
            end
          else
            (base_path || "") + path
          end
        end
      end

      def to_s
        url || ''
      end

    end # Url
  end # Uploader
end # CarrierWave

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/carrierwave-2.2.6/lib/carrierwave/uploader/url.rb
carrierwave-2.2.6 lib/carrierwave/uploader/url.rb
carrierwave-2.2.5 lib/carrierwave/uploader/url.rb
carrierwave-2.2.4 lib/carrierwave/uploader/url.rb
carrierwave-2.2.3 lib/carrierwave/uploader/url.rb
carrierwave-3.0.0.beta lib/carrierwave/uploader/url.rb
carrierwave-2.2.2 lib/carrierwave/uploader/url.rb
carrierwave-2.2.1 lib/carrierwave/uploader/url.rb
carrierwave-2.2.0 lib/carrierwave/uploader/url.rb