Class: Uploadcare::Api::Rest::FileMetadata
- Inherits:
-
Object
- Object
- Uploadcare::Api::Rest::FileMetadata
- Defined in:
- lib/uploadcare/api/rest/file_metadata.rb
Overview
REST API endpoint for file metadata operations.
Instance Attribute Summary collapse
-
#rest ⇒ Uploadcare::Api::Rest
readonly
Parent REST client.
Instance Method Summary collapse
-
#delete(uuid:, key:, request_options: {}) ⇒ Uploadcare::Result
Delete a metadata key for a file.
-
#index(uuid:, request_options: {}) ⇒ Uploadcare::Result
Get all metadata for a file.
-
#initialize(rest:) ⇒ FileMetadata
constructor
A new instance of FileMetadata.
-
#show(uuid:, key:, request_options: {}) ⇒ Uploadcare::Result
Get the value of a specific metadata key.
-
#update(uuid:, key:, value:, request_options: {}) ⇒ Uploadcare::Result
Update or create a metadata key for a file.
Constructor Details
#initialize(rest:) ⇒ FileMetadata
Returns a new instance of FileMetadata.
13 14 15 |
# File 'lib/uploadcare/api/rest/file_metadata.rb', line 13 def initialize(rest:) @rest = rest end |
Instance Attribute Details
#rest ⇒ Uploadcare::Api::Rest (readonly)
Returns Parent REST client.
10 11 12 |
# File 'lib/uploadcare/api/rest/file_metadata.rb', line 10 def rest @rest end |
Instance Method Details
#delete(uuid:, key:, request_options: {}) ⇒ Uploadcare::Result
Delete a metadata key for a file.
65 66 67 68 69 70 |
# File 'lib/uploadcare/api/rest/file_metadata.rb', line 65 def delete(uuid:, key:, request_options: {}) encoded_uuid = URI.encode_www_form_component(uuid) encoded_key = URI.encode_www_form_component(key) rest.request(method: :delete, path: "/files/#{encoded_uuid}/metadata/#{encoded_key}/", params: {}, headers: {}, request_options: ) end |
#index(uuid:, request_options: {}) ⇒ Uploadcare::Result
Get all metadata for a file.
23 24 25 26 27 |
# File 'lib/uploadcare/api/rest/file_metadata.rb', line 23 def index(uuid:, request_options: {}) encoded_uuid = URI.encode_www_form_component(uuid) rest.get(path: "/files/#{encoded_uuid}/metadata/", params: {}, headers: {}, request_options: ) end |
#show(uuid:, key:, request_options: {}) ⇒ Uploadcare::Result
Get the value of a specific metadata key.
36 37 38 39 40 41 |
# File 'lib/uploadcare/api/rest/file_metadata.rb', line 36 def show(uuid:, key:, request_options: {}) encoded_uuid = URI.encode_www_form_component(uuid) encoded_key = URI.encode_www_form_component(key) rest.get(path: "/files/#{encoded_uuid}/metadata/#{encoded_key}/", params: {}, headers: {}, request_options: ) end |
#update(uuid:, key:, value:, request_options: {}) ⇒ Uploadcare::Result
Update or create a metadata key for a file.
51 52 53 54 55 56 |
# File 'lib/uploadcare/api/rest/file_metadata.rb', line 51 def update(uuid:, key:, value:, request_options: {}) encoded_uuid = URI.encode_www_form_component(uuid) encoded_key = URI.encode_www_form_component(key) rest.put(path: "/files/#{encoded_uuid}/metadata/#{encoded_key}/", params: value.to_json, headers: {}, request_options: ) end |