imagekitio 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,72 @@
1
+ require "imagekitio/railtie"
2
+
3
+ require 'carrierwave'
4
+ require 'base64'
5
+ require_relative './carrierwave/storage/imagekit_store'
6
+ require_relative './carrierwave/storage/ik_file'
7
+ require_relative './carrierwave/support/uri_filename'
8
+ require_relative './imagekit/imagekit.rb'
9
+ require_relative "./imagekit/resource"
10
+ require_relative "./imagekit/file"
11
+ require_relative "./imagekit/url"
12
+ require_relative "./imagekit/utils/calculation"
13
+
14
+ module CarrierWave
15
+ module Uploader
16
+ class Base
17
+
18
+ def initialize(*)
19
+ ik_config=Rails.application.config.imagekit
20
+ @imagekit=ImageKit::ImageKitClient.new(ik_config[:private_key],ik_config[:public_key],ik_config[:url_endpoint])
21
+ @options={}
22
+ end
23
+
24
+ configure do |config|
25
+ config.storage_engines[:imagekit_store] = 'CarrierWave::Storage::ImageKitStore'
26
+ end
27
+
28
+ def filename
29
+ if options!=nil
30
+ @options=options
31
+ end
32
+ if self.file!=nil
33
+ base64=Base64.encode64(::File.open(self.file.file, "rb").read)
34
+ resp=@imagekit.upload_file(open(self.file.file,'rb'),self.file.filename,@options)
35
+ ::File.delete(self.file.file)
36
+ res=resp[:response].to_json
37
+ if res!="null"
38
+ res
39
+ else
40
+ "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}"
41
+ end
42
+ else
43
+ "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}"
44
+ end
45
+ end
46
+
47
+ def fileId
48
+ JSON.parse(self.identifier)['fileId']
49
+ end
50
+
51
+ def blob
52
+ JSON.parse(self.identifier)
53
+ end
54
+
55
+ def url_with(opt)
56
+ path=JSON.parse(self.identifier)['filePath']
57
+ opt[:path]=path
58
+ url=@imagekit.url(opt)
59
+ end
60
+
61
+ def url
62
+ JSON.parse(self.identifier)['url']
63
+ end
64
+
65
+ def options
66
+ options={}
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,4 @@
1
+ module Imagekitio
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :imagekitio do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imagekitio
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - ImageKit.io team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: 5.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 5.2.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 5.2.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: carrierwave
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.7'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.2'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0.7'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.2'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rest-client
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '2.1'
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.1'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '2.1'
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '2.1'
73
+ description: Automate image optimization on rails platforms.
74
+ email:
75
+ - developer@imagekit.io
76
+ executables: []
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - README.md
81
+ - Rakefile
82
+ - lib/carrierwave/storage/ik_file.rb
83
+ - lib/carrierwave/storage/imagekit_store.rb
84
+ - lib/carrierwave/support/uri_filename.rb
85
+ - lib/imagekit/constants/defaults.rb
86
+ - lib/imagekit/constants/errors.rb
87
+ - lib/imagekit/constants/file.rb
88
+ - lib/imagekit/constants/supported_transformation.rb
89
+ - lib/imagekit/constants/url.rb
90
+ - lib/imagekit/file.rb
91
+ - lib/imagekit/imagekit.rb
92
+ - lib/imagekit/resource.rb
93
+ - lib/imagekit/sdk/version.rb
94
+ - lib/imagekit/url.rb
95
+ - lib/imagekit/utils/calculation.rb
96
+ - lib/imagekit/utils/formatter.rb
97
+ - lib/imagekitio.rb
98
+ - lib/imagekitio/railtie.rb
99
+ - lib/tasks/imagekitio/imagekitio_tasks.rake
100
+ homepage: https://imagekit.io
101
+ licenses:
102
+ - MIT
103
+ metadata:
104
+ allowed_push_host: https://rubygems.org
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubygems_version: 3.0.3
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Automate image optimization on rails platforms.
124
+ test_files: []