cloudinary 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/cloudinary.gemspec +5 -0
- data/lib/active_storage/service/cloudinary_service.rb +52 -5
- data/lib/cloudinary/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f827756d17fc0b871d277a5bbdc6bc1ab3edeb30cf8765f29dd9fda17f6870d
|
4
|
+
data.tar.gz: 91e533b452f021f65255e26caed2271d5a96387a5c5728f5268720c9a2306fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 837eb7160f55eed0b1df45d041c2a8deb18ccd0acd6ee405cf70f151ee7926bf5715bd9852f7da21ef393a28e8ad630d40770d47ed7b296c915a98dd5fb8f417
|
7
|
+
data.tar.gz: a724d55a25e2b09a33d2c722021ad3c335a034e822961f86312916b6296902d1b65417ae0f630537fa10f603cf7ff28f98b291f648777d371d578524a0062ba9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
2.2.0 / 2024-09-08
|
2
|
+
==================
|
3
|
+
|
4
|
+
New functionality and features
|
5
|
+
------------------------------
|
6
|
+
|
7
|
+
* Add support for ActiveStorage model service configuration
|
8
|
+
|
9
|
+
Other Changes
|
10
|
+
-------------
|
11
|
+
|
12
|
+
* Fix asset type detection in ActiveStorage
|
13
|
+
* Add explicit `ostruct` dependency
|
14
|
+
|
15
|
+
2.1.2 / 2024-08-18
|
16
|
+
==================
|
17
|
+
|
18
|
+
* Fix ActiveStorage type detection for email files
|
19
|
+
* Add `changelog_uri` to `gemspec`
|
20
|
+
|
1
21
|
2.1.1 / 2024-05-28
|
2
22
|
==================
|
3
23
|
|
data/cloudinary.gemspec
CHANGED
@@ -13,6 +13,10 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.summary = %q{Client library for easily using the Cloudinary service}
|
14
14
|
s.description = %q{Client library for easily using the Cloudinary service}
|
15
15
|
|
16
|
+
s.metadata = {
|
17
|
+
"changelog_uri" => "https://github.com/cloudinary/cloudinary_gem/blob/master/CHANGELOG.md"
|
18
|
+
}
|
19
|
+
|
16
20
|
s.files = `git ls-files`.split("\n").select { |f| !f.start_with?("test", "spec", "features", "samples") } +
|
17
21
|
Dir.glob("vendor/assets/javascripts/*/*") + Dir.glob("vendor/assets/html/*")
|
18
22
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -23,6 +27,7 @@ Gem::Specification.new do |s|
|
|
23
27
|
s.add_dependency "faraday", ">= 2.0.1", "< 3.0.0"
|
24
28
|
s.add_dependency "faraday-multipart", "~> 1.0", ">= 1.0.4"
|
25
29
|
s.add_dependency 'faraday-follow_redirects', '~> 0.3.0'
|
30
|
+
s.add_dependency "ostruct"
|
26
31
|
|
27
32
|
s.add_development_dependency "rails", ">= 6.1.7", "< 8.0.0"
|
28
33
|
s.add_development_dependency "rexml", ">= 3.2.5", "< 4.0.0"
|
@@ -17,9 +17,13 @@ module CloudinaryHelper
|
|
17
17
|
alias cloudinary_url_internal_original cloudinary_url_internal
|
18
18
|
|
19
19
|
def cloudinary_url_internal(source, options = {})
|
20
|
-
|
21
|
-
|
20
|
+
service_instance, options = ActiveStorage::Service::CloudinaryService.fetch_service_instance_and_config(source, options)
|
21
|
+
service_instance ||= ActiveStorage::Blob.service
|
22
|
+
|
23
|
+
if defined?(service_instance.public_id) && options.fetch(:type, "").to_s != "fetch"
|
24
|
+
source = service_instance.public_id(source)
|
22
25
|
end
|
26
|
+
|
23
27
|
cloudinary_url_internal_original(source, options)
|
24
28
|
end
|
25
29
|
end
|
@@ -58,6 +62,7 @@ module ActiveStorage
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def url(key, filename: nil, content_type: '', **options)
|
65
|
+
key = find_blob_or_use_key(key)
|
61
66
|
instrument :url, key: key do |payload|
|
62
67
|
url = Cloudinary::Utils.cloudinary_url(
|
63
68
|
full_public_id_internal(key, options),
|
@@ -101,6 +106,7 @@ module ActiveStorage
|
|
101
106
|
end
|
102
107
|
|
103
108
|
def delete(key)
|
109
|
+
key = find_blob_or_use_key(key)
|
104
110
|
instrument :delete, key: key do
|
105
111
|
options = {
|
106
112
|
resource_type: resource_type(nil, key),
|
@@ -117,6 +123,7 @@ module ActiveStorage
|
|
117
123
|
end
|
118
124
|
|
119
125
|
def exist?(key)
|
126
|
+
key = find_blob_or_use_key(key)
|
120
127
|
instrument :exist, key: key do |payload|
|
121
128
|
begin
|
122
129
|
options = {
|
@@ -153,8 +160,7 @@ module ActiveStorage
|
|
153
160
|
|
154
161
|
# Return the partial content in the byte +range+ of the file at the +key+.
|
155
162
|
def download_chunk(key, range)
|
156
|
-
|
157
|
-
uri = URI(url)
|
163
|
+
uri = URI(url(key))
|
158
164
|
instrument :download, key: key do
|
159
165
|
req = Net::HTTP::Get.new(uri)
|
160
166
|
range_end = case
|
@@ -190,6 +196,33 @@ module ActiveStorage
|
|
190
196
|
full_public_id_internal(public_id)
|
191
197
|
end
|
192
198
|
|
199
|
+
def self.fetch_service_instance_and_config(source, options)
|
200
|
+
return [nil, options] unless defined?(ActiveStorage::BlobKey) && source.is_a?(ActiveStorage::BlobKey) &&
|
201
|
+
source.respond_to?(:attributes) && source.attributes.key?(:service_name)
|
202
|
+
|
203
|
+
service_name = source.attributes[:service_name]
|
204
|
+
|
205
|
+
begin
|
206
|
+
service_instance = ActiveStorage::Blob.services.fetch(service_name.to_sym)
|
207
|
+
|
208
|
+
unless service_instance.instance_of?(ActiveStorage::Service::CloudinaryService)
|
209
|
+
Rails.logger.error "Expected service instance #{service_instance.class.name} to be of type ActiveStorage::Service::CloudinaryService."
|
210
|
+
return [nil, options]
|
211
|
+
end
|
212
|
+
|
213
|
+
service_config = Rails.application.config.active_storage.service_configurations.fetch(service_name)
|
214
|
+
options = service_config.merge(options)
|
215
|
+
rescue NameError => e
|
216
|
+
Rails.logger.error "Failed to retrieve the service instance for #{service_name}: #{e.message}"
|
217
|
+
return [nil, options]
|
218
|
+
rescue => e
|
219
|
+
Rails.logger.error "An unexpected error occurred: #{e.message}"
|
220
|
+
return [nil, options]
|
221
|
+
end
|
222
|
+
|
223
|
+
[service_instance, options]
|
224
|
+
end
|
225
|
+
|
193
226
|
private
|
194
227
|
|
195
228
|
def api_uri(action, options)
|
@@ -255,7 +288,7 @@ module ActiveStorage
|
|
255
288
|
case type
|
256
289
|
when 'video', 'audio'
|
257
290
|
'video'
|
258
|
-
when 'text'
|
291
|
+
when 'text', 'message'
|
259
292
|
'raw'
|
260
293
|
when 'application'
|
261
294
|
case subtype
|
@@ -278,5 +311,19 @@ module ActiveStorage
|
|
278
311
|
end
|
279
312
|
content_type_to_resource_type(content_type)
|
280
313
|
end
|
314
|
+
|
315
|
+
def find_blob_or_use_key(key)
|
316
|
+
if key.is_a?(ActiveStorage::BlobKey)
|
317
|
+
key
|
318
|
+
else
|
319
|
+
begin
|
320
|
+
blob = ActiveStorage::Blob.find_by(key: key)
|
321
|
+
blob ? ActiveStorage::BlobKey.new(blob.attributes.as_json) : key
|
322
|
+
rescue ActiveRecord::StatementInvalid => e
|
323
|
+
# Return the original key if an error occurs
|
324
|
+
key
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
281
328
|
end
|
282
329
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nadav Soferman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-09-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ostruct
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -387,7 +401,8 @@ files:
|
|
387
401
|
homepage: https://cloudinary.com
|
388
402
|
licenses:
|
389
403
|
- MIT
|
390
|
-
metadata:
|
404
|
+
metadata:
|
405
|
+
changelog_uri: https://github.com/cloudinary/cloudinary_gem/blob/master/CHANGELOG.md
|
391
406
|
post_install_message:
|
392
407
|
rdoc_options: []
|
393
408
|
require_paths:
|