cloudinary 1.27.0 → 1.28.0

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: 46b21a3d7dd2411acaaeb35016f2ff7b648aeae5c1d077870f38e858ce1abedf
4
- data.tar.gz: 5825bea0988e97e71df1d93fde04739b502230cda987f90415cb46f55df8b6b7
3
+ metadata.gz: 97b754051e806086f5dfb98479292bb84bed48968c242d8c55dfa073a8d90e52
4
+ data.tar.gz: 6a6484d454b0b074fa177b68e90bb62a100c90aa3f4b3ab33dad9acd64d7ec4d
5
5
  SHA512:
6
- metadata.gz: 24c1334398c9c24ce9b0b536e991fb76aa633e1bda93b5e8dcccc1d2ac2f747e4645f52b61ad3b6db7bb9a59a092df602c35b964a05661c151fb6026cd1954c0
7
- data.tar.gz: f8f3cdbe7b7374532f5dae2f5dca3543697a2fb2398050b4a7874d6527b3e87ffc84970684aefe25c65f255ba9ec89e15470e28658c28287df781e4ee2144799
6
+ metadata.gz: dd822c6ec7144df3f7ab863d834802c486bc31ef5051cafbb9d331279a0f3092906990c211ccf1802515d53d51f64e71fd1bd73acc8a2f368c22bddd90ea3a38
7
+ data.tar.gz: cc2299facddd71188d08c0f934ad8483bc0c9414364699e3f84a20eee489f0883adca4ba838a9534d417e11580ff194761d0d26cc978079c9e3b2f42cceeaa48
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ 1.28.0 / 2023-11-06
2
+ ==================
3
+
4
+ New functionality and features
5
+ ------------------------------
6
+
7
+ * Add support for `image_file` parameter in `visual_search` Admin API
8
+ * Add support for `on_success` upload parameter
9
+
10
+ Other Changes
11
+ -------------
12
+
13
+ * Replace `update_all` to `update_column` in CarrierWave storage
14
+
1
15
  1.27.0 / 2023-07-31
2
16
  ==================
3
17
 
@@ -216,8 +216,9 @@ class Cloudinary::Api
216
216
  # @raise [Cloudinary::Api::Error]
217
217
  def self.visual_search(options = {})
218
218
  uri = "resources/visual_search"
219
- params = only(options, :image_url, :image_asset_id, :text)
220
- call_api(:get, uri, params, options)
219
+ params = only(options, :image_url, :image_asset_id, :text, :image_file)
220
+ params[:image_file] = Cloudinary::Utils.handle_file_param(params[:image_file]) if params.has_key?(:image_file)
221
+ call_api(:post, uri, params, options)
221
222
  end
222
223
 
223
224
  # Returns the details of the specified asset and all its derived assets.
@@ -82,14 +82,7 @@ class Cloudinary::CarrierWave::Storage < ::CarrierWave::Storage::Abstract
82
82
  end
83
83
 
84
84
  if defined?(ActiveRecord::Base) && uploader.model.is_a?(ActiveRecord::Base)
85
- primary_key = model_class.primary_key.to_sym
86
- if defined?(::ActiveRecord::VERSION::MAJOR) && ::ActiveRecord::VERSION::MAJOR > 2
87
- model_class.where(primary_key=>uploader.model.send(primary_key)).update_all(column=>name)
88
- else
89
- # Removed since active record version 3.0.0
90
- model_class.update_all({column=>name}, {primary_key=>uploader.model.send(primary_key)})
91
- end
92
- uploader.model.send :write_attribute, column, name
85
+ uploader.model.update_column(column, name)
93
86
  elsif defined?(Mongoid::Document) && uploader.model.is_a?(Mongoid::Document)
94
87
  # Mongoid support
95
88
  if Mongoid::VERSION.split(".").first.to_i >= 4
@@ -40,6 +40,7 @@ class Cloudinary::Uploader
40
40
  :eager_notification_url => options[:eager_notification_url],
41
41
  :exif => Cloudinary::Utils.as_safe_bool(options[:exif]),
42
42
  :eval => options[:eval],
43
+ :on_success => options[:on_success],
43
44
  :face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
44
45
  :faces => Cloudinary::Utils.as_safe_bool(options[:faces]),
45
46
  :folder => options[:folder],
@@ -87,16 +88,7 @@ class Cloudinary::Uploader
87
88
  def self.upload(file, options={})
88
89
  call_api("upload", options) do
89
90
  params = build_upload_params(options)
90
- if file.is_a?(Pathname)
91
- params[:file] = File.open(file, "rb")
92
- elsif file.is_a?(StringIO)
93
- file.rewind
94
- params[:file] = Cloudinary::Blob.new(file.read, options)
95
- elsif file.respond_to?(:read) || Cloudinary::Utils.is_remote?(file)
96
- params[:file] = file
97
- else
98
- params[:file] = File.open(file, "rb")
99
- end
91
+ params[:file] = Cloudinary::Utils.handle_file_param(file, options)
100
92
  [params, [:file]]
101
93
  end
102
94
  end
@@ -153,11 +145,7 @@ class Cloudinary::Uploader
153
145
  options[:resource_type] ||= :raw
154
146
  call_api("upload", options) do
155
147
  params = build_upload_params(options)
156
- if file.is_a?(Pathname) || !file.respond_to?(:read)
157
- params[:file] = File.open(file, "rb")
158
- else
159
- params[:file] = file
160
- end
148
+ params[:file] = Cloudinary::Utils.handle_file_param(file, options)
161
149
  [params, [:file]]
162
150
  end
163
151
  end
@@ -1295,6 +1295,27 @@ class Cloudinary::Utils
1295
1295
  }
1296
1296
  end
1297
1297
 
1298
+ # Handles file parameter.
1299
+ #
1300
+ # @param [Pathname, StringIO, File, String, int, _ToPath] file
1301
+ # @return [StringIO, File] A File object.
1302
+ #
1303
+ # @private
1304
+ def self.handle_file_param(file, options = {})
1305
+ if file.is_a?(Pathname)
1306
+ return File.open(file, "rb")
1307
+ elsif file.is_a?(Cloudinary::Blob)
1308
+ return file
1309
+ elsif file.is_a?(StringIO)
1310
+ file.rewind
1311
+ return Cloudinary::Blob.new(file.read, options)
1312
+ elsif file.respond_to?(:read) || Cloudinary::Utils.is_remote?(file)
1313
+ return file
1314
+ end
1315
+
1316
+ File.open(file, "rb")
1317
+ end
1318
+
1298
1319
  # The returned url should allow downloading the backedup asset based on the version and asset id
1299
1320
  #
1300
1321
  # asset and version id are returned with resource(<PUBLIC_ID1>, { versions: true })
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.27.0"
3
+ VERSION = "1.28.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: 1.27.0
4
+ version: 1.28.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: 2023-07-31 00:00:00.000000000 Z
13
+ date: 2023-11-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws_cf_signer