Sha256: e00e1d8d201de1c25b98bbadef682633893e313e46fcf53f419824180591d1a3

Contents?: true

Size: 781 Bytes

Versions: 21

Compression:

Stored size: 781 Bytes

Contents

class Cloudinary::PreloadedFile
  PRELOADED_CLOUDINARY_PATH = /^([^\/]+)\/([^\/]+)\/v(\d+)\/([^\/]+)#([^\/]+)$/

  attr_reader :filename, :version, :public_id, :signature, :resource_type, :type
  def initialize(file_info)
    @resource_type, @type, @version, @filename, @signature = file_info.scan(PRELOADED_CLOUDINARY_PATH).first    
    @public_id = @resource_type == "image" ? @filename[0..(@filename.rindex(".")-1)] : @filename
  end
  
  def valid?
    expected_signature = Cloudinary::Utils.api_sign_request({:public_id=>public_id, :version=>version}, Cloudinary.config.api_secret)
    @signature == expected_signature
  end
  
  def identifier
    "v#{version}/#{filename}"
  end
  
  def to_s
    "#{resource_type}/#{type}/v#{version}/#{filename}##{signature}"
  end
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
cloudinary-1.0.54 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.53 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.52 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.51 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.50 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.49 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.48 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.47 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.46 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.45 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.44 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.43 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.42 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.41 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.40 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.39 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.38 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.37 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.36 lib/cloudinary/preloaded_file.rb
cloudinary-1.0.35 lib/cloudinary/preloaded_file.rb