class CarrierWave::Uploader::Base
Public Class Methods
new(*)
click to toggle source
# File lib/myimagegemsdemo.rb, line 18 def initialize(*) ik_config=Rails.application.config.imagekit @imagekit=ImageKit::ImageKitClient.new(ik_config[:private_key],ik_config[:public_key],ik_config[:url_endpoint]) @options={} end
Public Instance Methods
blob()
click to toggle source
# File lib/myimagegemsdemo.rb, line 51 def blob JSON.parse(self.identifier) end
fileId()
click to toggle source
# File lib/myimagegemsdemo.rb, line 47 def fileId JSON.parse(self.identifier)['fileId'] end
filename()
click to toggle source
# File lib/myimagegemsdemo.rb, line 28 def filename if options!=nil @options=options end if self.file!=nil base64=Base64.encode64(::File.open(self.file.file, "rb").read) resp=@imagekit.upload_file(open(self.file.file,'rb'),self.file.filename,@options) ::File.delete(self.file.file) res=resp[:response].to_json if res!="null" res else "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}" end else "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}" end end
options()
click to toggle source
# File lib/myimagegemsdemo.rb, line 65 def options options={} end
url()
click to toggle source
# File lib/myimagegemsdemo.rb, line 61 def url JSON.parse(self.identifier)['url'] end
url_with(opt)
click to toggle source
# File lib/myimagegemsdemo.rb, line 55 def url_with(opt) path=JSON.parse(self.identifier)['filePath'] opt[:path]=path url=@imagekit.url(opt) end