Sha256: 0b680e8260aebb001a63f2f084fd3a18ffb1a593ccc1fa14a805da40d27fd64f

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 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
      uri = URI.parse(Cloudinary::Utils.smart_escape(Cloudinary::Utils.smart_unescape(uri)))
    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

3 entries across 3 versions & 1 rubygems

Version Path
cloudinary-1.16.1 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.16.0 lib/cloudinary/carrier_wave/remote.rb
cloudinary-1.15.0 lib/cloudinary/carrier_wave/remote.rb