Method: Cloudinary::Api.update

Defined in:
lib/cloudinary/api.rb

.update(public_id, options = {}) ⇒ Cloudinary::Api::Response

Updates details of an existing asset.

Update one or more of the attributes associated with a specified asset. Note that you can also update most attributes of an existing asset using the Uploader::explicit method, which is not rate limited.

Parameters:

  • public_id (String|Array)

    The public ID of the asset to update.

  • options (Hash) (defaults to: {})

    The optional parameters. See the Admin API documentation.

Returns:

Raises:

See Also:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/cloudinary/api.rb', line 271

def self.update(public_id, options={})
  resource_type  = options[:resource_type] || "image"
  type           = options[:type] || "upload"
  uri            = "resources/#{resource_type}/#{type}/#{public_id}"
  update_options = {
    :access_control     => Cloudinary::Utils.json_array_param(options[:access_control]),
    :asset_folder       => options[:asset_folder],
    :auto_tagging       => options[:auto_tagging] && options[:auto_tagging].to_f,
    :background_removal => options[:background_removal],
    :categorization     => options[:categorization],
    :context            => Cloudinary::Utils.encode_context(options[:context]),
    :custom_coordinates => Cloudinary::Utils.encode_double_array(options[:custom_coordinates]),
    :detection          => options[:detection],
    :display_name       => options[:display_name],
    :face_coordinates   => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
    :metadata           => Cloudinary::Utils.encode_context(options[:metadata]),
    :moderation_status  => options[:moderation_status],
    :notification_url   => options[:notification_url],
    :quality_override   => options[:quality_override],
    :ocr                => options[:ocr],
    :raw_convert        => options[:raw_convert],
    :similarity_search  => options[:similarity_search],
    :tags               => options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(","),
    :clear_invalid      => Cloudinary::Utils.as_safe_bool(options[:clear_invalid]),
    :unique_display_name=> options[:unique_display_name]
  }
  call_api(:post, uri, update_options, options)
end