Class: CarrierWave::Uploader::Base
- Inherits:
-
Object
- Object
- CarrierWave::Uploader::Base
- Defined in:
- lib/imagekitio.rb
Instance Method Summary collapse
- #blob ⇒ Object
- #fileId ⇒ Object
- #filename ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #options ⇒ Object
- #store_dir ⇒ Object
- #url ⇒ Object
- #url_with(opt) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 |
# File 'lib/imagekitio.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 |
Instance Method Details
#blob ⇒ Object
61 62 63 |
# File 'lib/imagekitio.rb', line 61 def blob JSON.parse(self.identifier) end |
#fileId ⇒ Object
57 58 59 |
# File 'lib/imagekitio.rb', line 57 def fileId JSON.parse(self.identifier)['fileId'] end |
#filename ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/imagekitio.rb', line 28 def filename if !=nil @options= end folder=nil begin folder=store_dir rescue end if folder!=nil @options[:folder]=folder 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 ⇒ Object
75 76 77 |
# File 'lib/imagekitio.rb', line 75 def ={} end |
#store_dir ⇒ Object
79 80 81 |
# File 'lib/imagekitio.rb', line 79 def store_dir store_dir=nil end |
#url ⇒ Object
71 72 73 |
# File 'lib/imagekitio.rb', line 71 def url JSON.parse(self.identifier)['url'] end |
#url_with(opt) ⇒ Object
65 66 67 68 69 |
# File 'lib/imagekitio.rb', line 65 def url_with(opt) path=JSON.parse(self.identifier)['filePath'] opt[:path]=path url=@imagekit.url(opt) end |