Module: CarrierWave::Uploader::Url
- Extended by:
- ActiveSupport::Concern
- Includes:
- Configuration, CarrierWave::Utilities::Uri
- Included in:
- Base
- Defined in:
- lib/carrierwave/uploader/url.rb
Constant Summary
Constants included from CarrierWave::Utilities::Uri
CarrierWave::Utilities::Uri::NON_ASCII, CarrierWave::Utilities::Uri::PATH_SAFE, CarrierWave::Utilities::Uri::PATH_UNSAFE
Instance Method Summary collapse
- #to_s ⇒ Object
-
#url(options = {}) ⇒ Object
Parameters.
Instance Method Details
#to_s ⇒ Object
38 39 40 |
# File 'lib/carrierwave/uploader/url.rb', line 38 def to_s url || '' end |
#url(options = {}) ⇒ Object
Parameters
- Hash
-
optional, the query params (only AWS)
Returns
- String
-
the location where this file is accessible via a url
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/carrierwave/uploader/url.rb', line 17 def url( = {}) if file.respond_to?(:url) tmp_url = file.method(:url).arity.zero? ? file.url : file.url() return tmp_url if tmp_url.present? end if file.respond_to?(:path) path = encode_path(file.path.sub(File.(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 |