cloudinary 1.0.55 → 1.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,19 +35,18 @@ module Cloudinary::CarrierWave
|
|
35
35
|
if args.first && !args.first.is_a?(Hash)
|
36
36
|
super
|
37
37
|
else
|
38
|
+
options = args.extract_options!
|
38
39
|
if self.blank?
|
39
40
|
url = self.default_url
|
40
41
|
return url if !url.blank?
|
41
42
|
public_id = self.default_public_id
|
42
43
|
return nil if public_id.nil?
|
43
44
|
else
|
44
|
-
public_id = self.full_public_id
|
45
|
+
public_id = options.include?(:version) ? self.my_public_id : self.full_public_id
|
45
46
|
end
|
46
|
-
options = args.extract_options!
|
47
47
|
options = self.transformation.merge(options) if self.version_name.present?
|
48
48
|
|
49
|
-
|
50
|
-
Cloudinary::Utils.cloudinary_url(public_id, {:format=>self.format, :resource_type=>resource_type, :type=>self.storage_type}.merge(options))
|
49
|
+
Cloudinary::Utils.cloudinary_url(public_id, {:format=>self.format, :resource_type=>self.resource_type, :type=>self.storage_type}.merge(options))
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -94,12 +93,11 @@ module Cloudinary::CarrierWave
|
|
94
93
|
return if from_public_id == to_public_id
|
95
94
|
|
96
95
|
@public_id = @stored_public_id = to_public_id
|
97
|
-
resource_type
|
98
|
-
if resource_type == 'raw'
|
96
|
+
if self.resource_type == 'raw'
|
99
97
|
from_public_id = [from_public_id, self.format].join(".")
|
100
98
|
to_public_id = [to_public_id, self.format].join(".")
|
101
99
|
end
|
102
|
-
Cloudinary::Uploader.rename(from_public_id, to_public_id, :type=>self.storage_type, :resource_type=>resource_type, :overwrite=>overwrite)
|
100
|
+
Cloudinary::Uploader.rename(from_public_id, to_public_id, :type=>self.storage_type, :resource_type=>self.resource_type, :overwrite=>overwrite)
|
103
101
|
storage.store_cloudinary_identifier(@stored_version, [@public_id, self.format].join("."))
|
104
102
|
end
|
105
103
|
|
@@ -142,9 +140,9 @@ module Cloudinary::CarrierWave
|
|
142
140
|
@uploader = uploader
|
143
141
|
@identifier = identifier
|
144
142
|
|
145
|
-
if @identifier.
|
146
|
-
version
|
147
|
-
@
|
143
|
+
if @identifier.match(%r(^v([0-9]+)/(.*)))
|
144
|
+
@version = $1
|
145
|
+
@filename = $2
|
148
146
|
else
|
149
147
|
@filename = @identifier
|
150
148
|
@version = nil
|
@@ -152,7 +150,7 @@ module Cloudinary::CarrierWave
|
|
152
150
|
|
153
151
|
@storage_type = uploader.class.storage_type
|
154
152
|
@resource_type = Cloudinary::Utils.resource_type_for_format(@filename)
|
155
|
-
@public_id, @format = Cloudinary::
|
153
|
+
@public_id, @format = Cloudinary::PreloadedFile.split_format(@filename)
|
156
154
|
end
|
157
155
|
|
158
156
|
def delete
|
@@ -170,15 +168,16 @@ module Cloudinary::CarrierWave
|
|
170
168
|
end
|
171
169
|
|
172
170
|
end
|
173
|
-
|
171
|
+
|
172
|
+
# @deprecated
|
174
173
|
def self.split_format(identifier)
|
175
|
-
|
176
|
-
return [identifier, nil] if last_dot.nil?
|
177
|
-
public_id = identifier[0, last_dot]
|
178
|
-
format = identifier[last_dot+1..-1]
|
179
|
-
return [public_id, format]
|
174
|
+
return Cloudinary::PreloadedFile.split_format(identifier)
|
180
175
|
end
|
181
176
|
|
177
|
+
def resource_type
|
178
|
+
Cloudinary::Utils.resource_type_for_format(self.filename || self.format)
|
179
|
+
end
|
180
|
+
|
182
181
|
# For the given methods - versions should call the main uploader method
|
183
182
|
def self.override_in_versions(base, *methods)
|
184
183
|
methods.each do
|
@@ -38,7 +38,6 @@ module Cloudinary::CarrierWave
|
|
38
38
|
class PreloadedCloudinaryFile < Cloudinary::PreloadedFile
|
39
39
|
def initialize(file_info)
|
40
40
|
super
|
41
|
-
raise CloudinaryException, "Cloudinary CarrierWave integration only supports uploaded images" if resource_type != "image" || type != "upload"
|
42
41
|
if !valid?
|
43
42
|
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.cloudinary_signature_error", :public_id=>public_id, :default=>"Invalid signature for #{public_id}")
|
44
43
|
end
|
@@ -140,7 +140,7 @@ module Cloudinary::CarrierWave
|
|
140
140
|
format = uploader.format
|
141
141
|
else
|
142
142
|
# Try to auto-detect format
|
143
|
-
format = Cloudinary::
|
143
|
+
format = Cloudinary::PreloadedFile.split_format(original_filename || "").last
|
144
144
|
format ||= "png" # TODO Default format?
|
145
145
|
end
|
146
146
|
format = format.to_s.downcase
|
@@ -5,6 +5,8 @@ class Cloudinary::CarrierWave::Storage < ::CarrierWave::Storage::Abstract
|
|
5
5
|
if uploader.is_main_uploader?
|
6
6
|
case file
|
7
7
|
when Cloudinary::CarrierWave::PreloadedCloudinaryFile
|
8
|
+
storage_type = uploader.class.storage_type || "upload"
|
9
|
+
raise CloudinaryException, "Uploader configured for type #{storage_type} but resource of type #{file.type} given." if storage_type != file.type
|
8
10
|
if uploader.public_id && uploader.auto_rename_preloaded?
|
9
11
|
@stored_version = file.version
|
10
12
|
uploader.rename(nil, true)
|
@@ -4,10 +4,11 @@ class Cloudinary::PreloadedFile
|
|
4
4
|
attr_reader :filename, :version, :public_id, :signature, :resource_type, :type
|
5
5
|
def initialize(file_info)
|
6
6
|
@resource_type, @type, @version, @filename, @signature = file_info.scan(PRELOADED_CLOUDINARY_PATH).first
|
7
|
-
@public_id
|
7
|
+
@public_id, @format = Cloudinary::PreloadedFile.split_format(@filename)
|
8
8
|
end
|
9
9
|
|
10
10
|
def valid?
|
11
|
+
public_id = @resource_type == "raw" ? self.filename : self.public_id
|
11
12
|
expected_signature = Cloudinary::Utils.api_sign_request({:public_id=>public_id, :version=>version}, Cloudinary.config.api_secret)
|
12
13
|
@signature == expected_signature
|
13
14
|
end
|
@@ -19,5 +20,13 @@ class Cloudinary::PreloadedFile
|
|
19
20
|
def to_s
|
20
21
|
"#{resource_type}/#{type}/v#{version}/#{filename}##{signature}"
|
21
22
|
end
|
23
|
+
|
24
|
+
def self.split_format(identifier)
|
25
|
+
last_dot = identifier.rindex(".")
|
26
|
+
return [identifier, nil] if last_dot.nil?
|
27
|
+
public_id = identifier[0, last_dot]
|
28
|
+
format = identifier[last_dot+1..-1]
|
29
|
+
return [public_id, format]
|
30
|
+
end
|
22
31
|
|
23
32
|
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.56
|
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: 2013-04-
|
14
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|