cloudinary 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0eb913c34bb7e22bdd7c72d748ce67956a73923772932137b4b3c3e58b922df
4
- data.tar.gz: b2d8aac422d47d0777b132c87649379d0a9535a83a84245202fecbd477d06803
3
+ metadata.gz: 8ebe1af18bba09305ed12b463059d3d48e7673590b355aea4aef072a6d437348
4
+ data.tar.gz: a2129cbe78b2642aff5a974dc209aca465f59d2ea23ebfdf8a65fa57b74b0468
5
5
  SHA512:
6
- metadata.gz: f224ae816b6485ae1abec08b6658037765139f46946f3679a4589083049d498121ff62a3af71f0d9b4ef2a918490dec0c3ffd0177439405037afe10e85138f06
7
- data.tar.gz: b6ad12381140938aa3f46342c36d0faba9350e9556e97d29c0a9db949d6e9bf84f709887072876cedd6e9190c60f141b96287db011aadef670717ceaae819e41
6
+ metadata.gz: 212ab056a1cd705c76551a754b257e63e498ee1cbb11dfcd60f4d4ef63cbfc208c2440ac8bc80908de7661ca724194d724a2cf841cef1d260e7807f05ebf60f3
7
+ data.tar.gz: 90f4997c9994df2c9f8de3c45b23a885d39c8fc9c2cb49504f694d224597ba39e3d5d20f2619e9c826fae015a50dbee9bb28ddb25b430a40c7ee05ab9f6bd1cb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ 2.1.0 / 2024-05-27
2
+ ==================
3
+
4
+ New functionality and features
5
+ ------------------------------
6
+
7
+ * Add support for `rename_folder` Admin API
8
+ * Add support for `delete_access_key` in Provisioning API
9
+
10
+ Other Changes
11
+ -------------
12
+
13
+ * Fix detection of base64 encoded files with complex MIME type
14
+ * Fix `fetch` url generation with Active Storage `folder` configuration
15
+ * Fix usage of deprecated `File.exists?` method
16
+
1
17
  2.0.2 / 2024-04-09
2
18
  ==================
3
19
 
@@ -17,7 +17,9 @@ module CloudinaryHelper
17
17
  alias cloudinary_url_internal_original cloudinary_url_internal
18
18
 
19
19
  def cloudinary_url_internal(source, options = {})
20
- source = ActiveStorage::Blob.service.public_id(source) if defined? ActiveStorage::Blob.service.public_id
20
+ if defined?(ActiveStorage::Blob.service.public_id) && options.fetch(:type, "").to_s != "fetch"
21
+ source = ActiveStorage::Blob.service.public_id(source)
22
+ end
21
23
  cloudinary_url_internal_original(source, options)
22
24
  end
23
25
  end
@@ -58,7 +60,7 @@ module ActiveStorage
58
60
  def url(key, filename: nil, content_type: '', **options)
59
61
  instrument :url, key: key do |payload|
60
62
  url = Cloudinary::Utils.cloudinary_url(
61
- full_public_id_internal(key),
63
+ full_public_id_internal(key, options),
62
64
  resource_type: resource_type(nil, key, content_type),
63
65
  format: ext_for_file(key, filename, content_type),
64
66
  **@options.merge(options.symbolize_keys)
@@ -231,10 +233,12 @@ module ActiveStorage
231
233
  end
232
234
 
233
235
  # Returns the full public id including folder.
234
- def full_public_id_internal(key)
236
+ def full_public_id_internal(key, options = {})
235
237
  public_id = public_id_internal(key)
236
238
 
237
- return public_id unless @options[:folder]
239
+ options = @options.merge(options)
240
+
241
+ return public_id if !options[:folder] || options.fetch(:type).to_s == "fetch"
238
242
 
239
243
  File.join(@options.fetch(:folder), public_id)
240
244
  end
@@ -260,6 +260,24 @@ class Cloudinary::AccountApi
260
260
  call_account_api(:put, ['sub_accounts', sub_account_id, 'access_keys', api_key], params, options.merge(content_type: :json))
261
261
  end
262
262
 
263
+ # Deletes access key.
264
+ #
265
+ # @param [String] sub_account_id The ID of the sub-account.
266
+ # @param [String, nil] api_key The API key.
267
+ # @param [String, nil] name The display name as shown in the management console.
268
+ # @param [Object] options Additional options.
269
+ def self.delete_access_key(sub_account_id, api_key = nil, name = nil, options = {})
270
+ uri = ['sub_accounts', sub_account_id, 'access_keys']
271
+ unless api_key.blank?
272
+ uri.append(api_key)
273
+ end
274
+
275
+ params = {
276
+ name: name,
277
+ }
278
+ call_account_api(:delete, uri, params, options.merge(content_type: :json))
279
+ end
280
+
263
281
  def self.call_account_api(method, uri, params, options)
264
282
  account_id = options[:account_id] || Cloudinary.account_config.account_id || raise('Must supply account_id')
265
283
  api_key = options[:provisioning_api_key] || Cloudinary.account_config.provisioning_api_key || raise('Must supply provisioning api_key')
@@ -731,6 +731,21 @@ class Cloudinary::Api
731
731
  call_api(:post, "folders/#{folder_name}", {}, options)
732
732
  end
733
733
 
734
+ # Renames existing asset folder.
735
+ #
736
+ # @param [String] from_path The full path of an existing asset folder.
737
+ # @param [String] to_path The full path of the new asset folder.
738
+ # @param [Hash] options The optional parameters.
739
+ #
740
+ # @return [Cloudinary::Api::Response]
741
+ #
742
+ # @raise [Cloudinary::Api::Error]
743
+ #
744
+ # @see https://cloudinary.com/documentation/admin_api#rename_folder
745
+ def self.rename_folder(from_path, to_path, options={})
746
+ call_api(:put, "folders/#{from_path}", {:to_folder => to_path}, options)
747
+ end
748
+
734
749
  # Lists upload mappings by folder and its mapped template (URL).
735
750
  #
736
751
  # @param [Hash] options The optional parameters. See the
@@ -179,7 +179,7 @@ module CloudinaryHelper
179
179
  version_store = options.delete(:version_store)
180
180
  if options[:version].blank? && (version_store == :file) && defined?(Rails) && defined?(Rails.root)
181
181
  file_name = "#{Rails.root}/tmp/cloudinary/cloudinary_sprite_#{source.sub(/\..*/, '')}.version"
182
- if File.exists?(file_name)
182
+ if File.exist?(file_name)
183
183
  options[:version] = File.read(file_name).chomp
184
184
  end
185
185
  end
@@ -153,7 +153,7 @@ class Cloudinary::Utils
153
153
  zoom
154
154
  ].map(&:to_sym)
155
155
 
156
- REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)
156
+ REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\.[\w-]+)*(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)
157
157
 
158
158
  LONG_URL_SIGNATURE_LENGTH = 32
159
159
  SHORT_URL_SIGNATURE_LENGTH = 8
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.0"
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: 2.0.2
4
+ version: 2.1.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-04-09 00:00:00.000000000 Z
13
+ date: 2024-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday