cloudinary 1.0.41 → 1.0.42
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cloudinary.rb +1 -0
- data/lib/cloudinary/api.rb +1 -1
- data/lib/cloudinary/carrier_wave/preloaded.rb +1 -1
- data/lib/cloudinary/carrier_wave/process.rb +2 -2
- data/lib/cloudinary/carrier_wave/storage.rb +2 -2
- data/lib/cloudinary/exceptions.rb +2 -0
- data/lib/cloudinary/helper.rb +2 -2
- data/lib/cloudinary/migrator.rb +2 -2
- data/lib/cloudinary/uploader.rb +8 -5
- data/lib/cloudinary/utils.rb +18 -12
- data/lib/cloudinary/version.rb +1 -1
- metadata +3 -2
data/lib/cloudinary.rb
CHANGED
data/lib/cloudinary/api.rb
CHANGED
@@ -38,7 +38,7 @@ module Cloudinary::CarrierWave
|
|
38
38
|
class PreloadedCloudinaryFile < Cloudinary::PreloadedFile
|
39
39
|
def initialize(file_info)
|
40
40
|
super
|
41
|
-
raise "Cloudinary CarrierWave integration only supports uploaded images" if resource_type != "image" || type != "upload"
|
41
|
+
raise CloudinaryException, "Cloudinary CarrierWave integration only supports uploaded images" if resource_type != "image" || type != "upload"
|
42
42
|
if !valid?
|
43
43
|
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.cloudinary_signature_error", :public_id=>public_id, :default=>"Invalid signature for #{public_id}")
|
44
44
|
end
|
@@ -51,7 +51,7 @@ module Cloudinary::CarrierWave
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def set_or_yell(hash, attr, value)
|
54
|
-
raise "conflicting transformation on #{attr} #{value}!=#{hash[attr]}" if hash[attr] && hash[attr] != value
|
54
|
+
raise CloudinaryException, "conflicting transformation on #{attr} #{value}!=#{hash[attr]}" if hash[attr] && hash[attr] != value
|
55
55
|
hash[attr] = value
|
56
56
|
end
|
57
57
|
|
@@ -123,7 +123,7 @@ module Cloudinary::CarrierWave
|
|
123
123
|
|
124
124
|
def tags
|
125
125
|
@tags ||= self.all_processors.select{|processor| processor[0] == :tags}.map(&:second).first
|
126
|
-
raise "tags cannot be used in versions." if @tags.present? && self.version_name.present?
|
126
|
+
raise CloudinaryException, "tags cannot be used in versions." if @tags.present? && self.version_name.present?
|
127
127
|
@tags
|
128
128
|
end
|
129
129
|
|
@@ -36,7 +36,7 @@ class Cloudinary::CarrierWave::Storage < ::CarrierWave::Storage::Abstract
|
|
36
36
|
store_cloudinary_version(uploader.metadata["version"]) if uploader.metadata["version"]
|
37
37
|
# Will throw an exception on error
|
38
38
|
else
|
39
|
-
raise "nested versions are not allowed." if (uploader.class.version_names.length > 1)
|
39
|
+
raise CloudinaryException, "nested versions are not allowed." if (uploader.class.version_names.length > 1)
|
40
40
|
# Do nothing - versions are not handled locally.
|
41
41
|
end
|
42
42
|
nil
|
@@ -57,7 +57,7 @@ class Cloudinary::CarrierWave::Storage < ::CarrierWave::Storage::Abstract
|
|
57
57
|
model_class.where(:_id=>uploader.model._id).update_all(column=>name)
|
58
58
|
uploader.model.send :write_attribute, column, name
|
59
59
|
else
|
60
|
-
raise "Only ActiveRecord and Mongoid are supported at the moment!"
|
60
|
+
raise CloudinaryException, "Only ActiveRecord and Mongoid are supported at the moment!"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/cloudinary/helper.rb
CHANGED
@@ -130,8 +130,8 @@ module CloudinaryHelper
|
|
130
130
|
html_options = options.delete(:html) || {}
|
131
131
|
cloudinary_upload_url = Cloudinary::Utils.cloudinary_api_url("upload", {:resource_type=>:auto}.merge(options))
|
132
132
|
|
133
|
-
api_key = options[:api_key] || Cloudinary.config.api_key || raise("Must supply api_key")
|
134
|
-
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise("Must supply api_secret")
|
133
|
+
api_key = options[:api_key] || Cloudinary.config.api_key || raise(CloudinaryException, "Must supply api_key")
|
134
|
+
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise(CloudinaryException, "Must supply api_secret")
|
135
135
|
|
136
136
|
cloudinary_params = Cloudinary::Uploader.build_upload_params(options)
|
137
137
|
cloudinary_params[:callback] = build_callback_url(options)
|
data/lib/cloudinary/migrator.rb
CHANGED
@@ -87,8 +87,8 @@ class Cloudinary::Migrator
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def process(options={})
|
90
|
-
raise "url not given and no retieve callback given" if options[:url].nil? && self.retrieve.nil?
|
91
|
-
raise "id not given and retieve or complete callback given" if options[:id].nil? && (!self.retrieve.nil? || !self.complete.nil?)
|
90
|
+
raise CloudinaryException, "url not given and no retieve callback given" if options[:url].nil? && self.retrieve.nil?
|
91
|
+
raise CloudinaryException, "id not given and retieve or complete callback given" if options[:id].nil? && (!self.retrieve.nil? || !self.complete.nil?)
|
92
92
|
|
93
93
|
debug("Process: #{options.inspect}")
|
94
94
|
start
|
data/lib/cloudinary/uploader.rb
CHANGED
@@ -22,6 +22,9 @@ class Cloudinary::Uploader
|
|
22
22
|
:format=>options[:format],
|
23
23
|
:type=>options[:type],
|
24
24
|
:backup=>options[:backup],
|
25
|
+
:faces=>options[:faces],
|
26
|
+
:exif=>options[:exif],
|
27
|
+
:colors=>options[:colors],
|
25
28
|
:invalidate=>options[:invalidate],
|
26
29
|
:eager=>build_eager(options[:eager]),
|
27
30
|
:headers=>build_custom_headers(options[:headers]),
|
@@ -137,8 +140,8 @@ class Cloudinary::Uploader
|
|
137
140
|
def self.call_api(action, options)
|
138
141
|
options = options.clone
|
139
142
|
return_error = options.delete(:return_error)
|
140
|
-
api_key = options[:api_key] || Cloudinary.config.api_key || raise("Must supply api_key")
|
141
|
-
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise("Must supply api_secret")
|
143
|
+
api_key = options[:api_key] || Cloudinary.config.api_key || raise(CloudinaryException, "Must supply api_key")
|
144
|
+
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise(CloudinaryException, "Must supply api_secret")
|
142
145
|
|
143
146
|
params, non_signable = yield
|
144
147
|
non_signable ||= []
|
@@ -152,18 +155,18 @@ class Cloudinary::Uploader
|
|
152
155
|
|
153
156
|
RestClient::Request.execute(:method => :post, :url => api_url, :payload => params.reject{|k, v| v.nil? || v==""}, :timeout=>60) do
|
154
157
|
|response, request, tmpresult|
|
155
|
-
raise "Server returned unexpected status code - #{response.code} - #{response.body}" if ![200,400,500].include?(response.code)
|
158
|
+
raise CloudinaryException, "Server returned unexpected status code - #{response.code} - #{response.body}" if ![200,400,500].include?(response.code)
|
156
159
|
begin
|
157
160
|
result = Cloudinary::Utils.json_decode(response.body)
|
158
161
|
rescue => e
|
159
162
|
# Error is parsing json
|
160
|
-
raise "Error parsing server response (#{response.code}) - #{response.body}. Got - #{e}"
|
163
|
+
raise CloudinaryException, "Error parsing server response (#{response.code}) - #{response.body}. Got - #{e}"
|
161
164
|
end
|
162
165
|
if result["error"]
|
163
166
|
if return_error
|
164
167
|
result["error"]["http_code"] = response.code
|
165
168
|
else
|
166
|
-
raise result["error"]["message"]
|
169
|
+
raise CloudinaryException, result["error"]["message"]
|
167
170
|
end
|
168
171
|
end
|
169
172
|
end
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -88,7 +88,7 @@ class Cloudinary::Utils
|
|
88
88
|
resource_type = options.delete(:resource_type) || "image"
|
89
89
|
version = options.delete(:version)
|
90
90
|
format = options.delete(:format)
|
91
|
-
cloud_name = options.delete(:cloud_name) || Cloudinary.config.cloud_name || raise("Must supply cloud_name in tag or in configuration")
|
91
|
+
cloud_name = options.delete(:cloud_name) || Cloudinary.config.cloud_name || raise(CloudinaryException, "Must supply cloud_name in tag or in configuration")
|
92
92
|
secure = options.delete(:secure)
|
93
93
|
ssl_detected = options.delete(:ssl_detected)
|
94
94
|
secure = ssl_detected || Cloudinary.config.secure if secure.nil?
|
@@ -133,7 +133,7 @@ class Cloudinary::Utils
|
|
133
133
|
else
|
134
134
|
if secure && secure_distribution.nil?
|
135
135
|
if private_cdn
|
136
|
-
raise "secure_distribution not defined"
|
136
|
+
raise CloudinaryException, "secure_distribution not defined"
|
137
137
|
else
|
138
138
|
secure_distribution = SHARED_CDN
|
139
139
|
end
|
@@ -156,23 +156,29 @@ class Cloudinary::Utils
|
|
156
156
|
|
157
157
|
def self.cloudinary_api_url(action = 'upload', options = {})
|
158
158
|
cloudinary = options[:upload_prefix] || Cloudinary.config.upload_prefix || "https://api.cloudinary.com"
|
159
|
-
cloud_name = options[:cloud_name] || Cloudinary.config.cloud_name || raise("Must supply cloud_name")
|
159
|
+
cloud_name = options[:cloud_name] || Cloudinary.config.cloud_name || raise(CloudinaryException, "Must supply cloud_name")
|
160
160
|
resource_type = options[:resource_type] || "image"
|
161
161
|
return [cloudinary, "v1_1", cloud_name, resource_type, action].join("/")
|
162
162
|
end
|
163
163
|
|
164
164
|
def self.private_download_url(public_id, format, options = {})
|
165
|
-
api_key = options[:api_key] || Cloudinary.config.api_key || raise("Must supply api_key")
|
166
|
-
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise("Must supply api_secret")
|
167
|
-
cloudinary_params = {
|
165
|
+
api_key = options[:api_key] || Cloudinary.config.api_key || raise(CloudinaryException, "Must supply api_key")
|
166
|
+
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise(CloudinaryException, "Must supply api_secret")
|
167
|
+
cloudinary_params = {
|
168
|
+
:timestamp=>Time.now.to_i,
|
169
|
+
:public_id=>public_id,
|
170
|
+
:format=>format,
|
171
|
+
:type=>options[:type],
|
172
|
+
:expires_at=>options[:expires_at] && options[:expires_at].to_i
|
173
|
+
}.reject{|k, v| v.blank?}
|
168
174
|
cloudinary_params[:signature] = Cloudinary::Utils.api_sign_request(cloudinary_params, api_secret)
|
169
175
|
cloudinary_params[:api_key] = api_key
|
170
176
|
return Cloudinary::Utils.cloudinary_api_url("download", options) + "?" + cloudinary_params.to_query
|
171
177
|
end
|
172
178
|
|
173
179
|
def self.zip_download_url(tag, options = {})
|
174
|
-
api_key = options[:api_key] || Cloudinary.config.api_key || raise("Must supply api_key")
|
175
|
-
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise("Must supply api_secret")
|
180
|
+
api_key = options[:api_key] || Cloudinary.config.api_key || raise(CloudinaryException, "Must supply api_key")
|
181
|
+
api_secret = options[:api_secret] || Cloudinary.config.api_secret || raise(CloudinaryException, "Must supply api_secret")
|
176
182
|
cloudinary_params = {:timestamp=>Time.now.to_i, :tag=>tag, :transformation=>generate_transformation_string(options)}.reject{|k, v| v.blank?}
|
177
183
|
cloudinary_params[:signature] = Cloudinary::Utils.api_sign_request(cloudinary_params, api_secret)
|
178
184
|
cloudinary_params[:api_key] = api_key
|
@@ -180,9 +186,9 @@ class Cloudinary::Utils
|
|
180
186
|
end
|
181
187
|
|
182
188
|
def self.signed_download_url(public_id, options = {})
|
183
|
-
aws_private_key_path = options[:aws_private_key_path] || Cloudinary.config.aws_private_key_path || raise("Must supply aws_private_key_path")
|
184
|
-
aws_key_pair_id = options[:aws_key_pair_id] || Cloudinary.config.aws_key_pair_id || raise("Must supply aws_key_pair_id")
|
185
|
-
authenticated_distribution = options[:authenticated_distribution] || Cloudinary.config.authenticated_distribution || raise("Must supply authenticated_distribution")
|
189
|
+
aws_private_key_path = options[:aws_private_key_path] || Cloudinary.config.aws_private_key_path || raise(CloudinaryException, "Must supply aws_private_key_path")
|
190
|
+
aws_key_pair_id = options[:aws_key_pair_id] || Cloudinary.config.aws_key_pair_id || raise(CloudinaryException, "Must supply aws_key_pair_id")
|
191
|
+
authenticated_distribution = options[:authenticated_distribution] || Cloudinary.config.authenticated_distribution || raise(CloudinaryException, "Must supply authenticated_distribution")
|
186
192
|
@signers ||= Hash.new{|h,k| path, id = k; h[k] = AwsCfSigner.new(path, id)}
|
187
193
|
signer = @signers[[aws_private_key_path, aws_key_pair_id]]
|
188
194
|
url = Cloudinary::Utils.unsigned_download_url(public_id, {:type=>:authenticated}.merge(options).merge(:secure=>true, :secure_distribution=>authenticated_distribution, :private_cdn=>true))
|
@@ -233,7 +239,7 @@ class Cloudinary::Utils
|
|
233
239
|
begin
|
234
240
|
require 'active_support/json'
|
235
241
|
rescue LoadError
|
236
|
-
raise "Please add the json gem or active_support to your Gemfile"
|
242
|
+
raise LoadError, "Please add the json gem or active_support to your Gemfile"
|
237
243
|
end
|
238
244
|
end
|
239
245
|
end
|
data/lib/cloudinary/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.42
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/cloudinary/controller.rb
|
89
89
|
- lib/cloudinary/downloader.rb
|
90
90
|
- lib/cloudinary/engine.rb
|
91
|
+
- lib/cloudinary/exceptions.rb
|
91
92
|
- lib/cloudinary/helper.rb
|
92
93
|
- lib/cloudinary/migrator.rb
|
93
94
|
- lib/cloudinary/missing.rb
|