Sha256: 84514b11193102348cebc9410aa59f5b399598b9a472b5f23e89a0610cf364d2

Contents?: true

Size: 933 Bytes

Versions: 20

Compression:

Stored size: 933 Bytes

Contents

module Cloudinary::CarrierWave
  def download!(uri, *args)
    return super unless self.cloudinary_should_handle_remote?
    if respond_to?(:process_uri)
      uri = process_uri(uri)
    else # Backward compatibility with old CarrierWave
      remote_url_unsafe_chars = /([^a-zA-Z0-9_.\-\/:?&=]+)/ # In addition allow query string characters: "?","&" and "="
      uri = URI.parse(Cloudinary::Utils.smart_escape(Cloudinary::Utils.smart_unescape(uri), remote_url_unsafe_chars))
    end
    return if uri.to_s.blank?
    self.original_filename = @cache_id = @filename = File.basename(uri.path).gsub(/[^a-zA-Z0-9\.\-\+_]/, '')
    @file = RemoteFile.new(uri, @filename)
  end

  class RemoteFile
    attr_reader :uri, :original_filename
    def initialize(uri, filename)
      @uri = uri
      @original_filename = filename
    end

    def delete
      # Do nothing. This is a virtual file.
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
cloudinary-2.2.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-2.1.2 lib/cloudinary/carrier_wave/remote.rb
cloudinary-2.0.2 lib/cloudinary/carrier_wave/remote.rb
cloudinary-2.0.1 lib/cloudinary/carrier_wave/remote.rb
cloudinary-2.0.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.29.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.28.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.27.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.26.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.25.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.24.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.23.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.22.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.21.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.20.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.19.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.18.1 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.18.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.17.1 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.17.0 lib/cloudinary/carrier_wave/remote.rb