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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bd2d8e8b2dc86a6dfd91a1d47cceacd541c46b71dc2ac10bb6972674067cea0
4
- data.tar.gz: a3af6a9f260fa2a3c3390e5640535ec916c3c4487a806fe9e187b620551d92d1
3
+ metadata.gz: ab5096280e7accb34f68e18a4979931fa98f0c03bfae01913b388679e499f332
4
+ data.tar.gz: 6d6afe81d600578d1741d5f4fb0b3a04c98bde8d9320cea260a4b371e8cd3a02
5
5
  SHA512:
6
- metadata.gz: 0761a1868f2c4fe403b874d510ea44df4b164bc1cf9f30b44d55f074b066fd1634accf98e2adf6bb3e76ee081790f26bc833781371272302cc4c9c41c7c3c190
7
- data.tar.gz: 13291d1b0e99402d7cb043fc63d200444646785f1d812e6b323c8e82db2b3034caad6b75796ddaee4d3ab0f99389fecb6445df513e09ce01e6213f492c6e7d6b
6
+ metadata.gz: 577d651df8534d2a1e294b6b86040507fff83d3af3176c91d436c528145459c110786ae49793a3aa589ae8d9d6107606a2854e5b494ba2207f74174390cb39e7
7
+ data.tar.gz: 9e8857df349c08949ad9e3327e2d4acad3f7bd4c4f36a667a9e5940f47555df92522ddd9e5cbe55387674994364b1087913bc5e7674f530eacd35a592470ef42
@@ -1,4 +1,9 @@
1
1
 
2
+ 1.13.2 / 2020-01-19
3
+ ===================
4
+
5
+ * Fix asset extension detection in active storage service `url` method
6
+
2
7
  1.13.1 / 2019-11-24
3
8
  ===================
4
9
 
@@ -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: ext_for_content_type(content_type),
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
- def ext_for_content_type(content_type)
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 resource_type(io, key = "")
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
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.13.1"
3
+ VERSION = "1.13.2"
4
4
  end
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.1
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: 2019-11-24 00:00:00.000000000 Z
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