cloudinary 1.13.1 → 1.13.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/active_storage/service/cloudinary_service.rb +25 -5
- data/lib/cloudinary/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab5096280e7accb34f68e18a4979931fa98f0c03bfae01913b388679e499f332
|
4
|
+
data.tar.gz: 6d6afe81d600578d1741d5f4fb0b3a04c98bde8d9320cea260a4b371e8cd3a02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577d651df8534d2a1e294b6b86040507fff83d3af3176c91d436c528145459c110786ae49793a3aa589ae8d9d6107606a2854e5b494ba2207f74174390cb39e7
|
7
|
+
data.tar.gz: 9e8857df349c08949ad9e3327e2d4acad3f7bd4c4f36a667a9e5940f47555df92522ddd9e5cbe55387674994364b1087913bc5e7674f530eacd35a592470ef42
|
data/CHANGELOG.md
CHANGED
@@ -48,9 +48,10 @@ module ActiveStorage
|
|
48
48
|
url = Cloudinary::Utils.cloudinary_url(
|
49
49
|
public_id(key),
|
50
50
|
resource_type: resource_type(nil, key),
|
51
|
-
format:
|
51
|
+
format: ext_for_file(filename, content_type),
|
52
52
|
**@options.merge(options.symbolize_keys)
|
53
53
|
)
|
54
|
+
|
54
55
|
payload[:url] = url
|
55
56
|
|
56
57
|
url
|
@@ -149,7 +150,22 @@ module ActiveStorage
|
|
149
150
|
"#{base_url}?#{upload_params.to_query}"
|
150
151
|
end
|
151
152
|
|
152
|
-
|
153
|
+
# Helper method for getting the filename extension.
|
154
|
+
#
|
155
|
+
# It does the best effort when original filename does not include extension, but we know the mime-type.
|
156
|
+
#
|
157
|
+
# @param [ActiveStorage::Filename] filename The original filename.
|
158
|
+
# @param [string] content_type The content type of the file.
|
159
|
+
#
|
160
|
+
# @return [string] The extension of the filename.
|
161
|
+
def ext_for_file(filename, content_type)
|
162
|
+
ext = filename.respond_to?(:extension_without_delimiter) ? filename.extension_without_delimiter : nil
|
163
|
+
return ext unless ext.blank?
|
164
|
+
|
165
|
+
# Raw files are not convertible, no extension guessing for them
|
166
|
+
return nil if content_type_to_resource_type(content_type).eql?('raw')
|
167
|
+
|
168
|
+
# Fallback when there is no extension.
|
153
169
|
@formats ||= Hash.new do |h, key|
|
154
170
|
ext = Rack::Mime::MIME_TYPES.invert[key]
|
155
171
|
h[key] = ext.slice(1..-1) unless ext.nil?
|
@@ -162,9 +178,7 @@ module ActiveStorage
|
|
162
178
|
key
|
163
179
|
end
|
164
180
|
|
165
|
-
def
|
166
|
-
options = key.respond_to?(:attributes) ? key.attributes : {}
|
167
|
-
content_type = options[:content_type] || (io.nil? ? '' : Marcel::MimeType.for(io))
|
181
|
+
def content_type_to_resource_type(content_type)
|
168
182
|
type, subtype = content_type.split('/')
|
169
183
|
case type
|
170
184
|
when 'video', 'audio'
|
@@ -184,5 +198,11 @@ module ActiveStorage
|
|
184
198
|
'image'
|
185
199
|
end
|
186
200
|
end
|
201
|
+
|
202
|
+
def resource_type(io, key = "")
|
203
|
+
options = key.respond_to?(:attributes) ? key.attributes : {}
|
204
|
+
content_type = options[:content_type] || (io.nil? ? '' : Marcel::MimeType.for(io))
|
205
|
+
content_type_to_resource_type(content_type)
|
206
|
+
end
|
187
207
|
end
|
188
208
|
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.13.
|
4
|
+
version: 1.13.2
|
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:
|
13
|
+
date: 2020-01-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws_cf_signer
|