Class: CarrierWave::Storage::IKFile

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/storage/ik_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ IKFile

Initialize as required.



6
7
8
9
10
# File 'lib/carrierwave/storage/ik_file.rb', line 6

def initialize(identifier)
  @identifier=JSON.parse(identifier)
  ik_config=Rails.application.config.imagekit
  @imagekit=ImageKit::ImageKitClient.new(ik_config[:private_key],ik_config[:public_key],ik_config[:url_endpoint])
end

Instance Method Details

#content_typeObject

Duck-type methods for CarrierWave::SanitizedFile.



13
14
15
# File 'lib/carrierwave/storage/ik_file.rb', line 13

def content_type
    "image/jpg"
end

#deleteObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/carrierwave/storage/ik_file.rb', line 33

def delete
  # file_id=@identifier['fileId']
  begin
    @imagekit.delete_file(fileId)
  rescue
    fileId
  end
  # binding.pry
  # return nil
end

#exists?Boolean

binding.pry return nil

Returns:

  • (Boolean)


43
44
# File 'lib/carrierwave/storage/ik_file.rb', line 43

def exists?
end

#fileIdObject



23
24
25
# File 'lib/carrierwave/storage/ik_file.rb', line 23

def fileId
  @identifier['fileId']
end

#filename(options = {}) ⇒ Object



26
27
28
# File 'lib/carrierwave/storage/ik_file.rb', line 26

def filename(options = {})
  @identifier['name']
end

#public_urlObject



16
17
18
# File 'lib/carrierwave/storage/ik_file.rb', line 16

def public_url
  @identifier['url']
end

#readObject



29
30
# File 'lib/carrierwave/storage/ik_file.rb', line 29

def read
end

#sizeObject



31
32
# File 'lib/carrierwave/storage/ik_file.rb', line 31

def size
end

#url(options = {}) ⇒ Object



19
20
21
# File 'lib/carrierwave/storage/ik_file.rb', line 19

def url(options = {})
  @identifier['url']
end