Class: Imagekitio::Models::Beta::V2::FileUploadParams
- Inherits:
-
Internal::Type::BaseModel
- Object
- Internal::Type::BaseModel
- Imagekitio::Models::Beta::V2::FileUploadParams
- Extended by:
- Internal::Type::RequestParameters::Converter
- Includes:
- Internal::Type::RequestParameters
- Defined in:
- lib/imagekitio/models/beta/v2/file_upload_params.rb
Overview
Defined Under Namespace
Modules: ResponseField Classes: Transformation
Instance Attribute Summary collapse
-
#checks ⇒ String?
Server-side checks to run on the asset.
-
#custom_coordinates ⇒ String?
Define an important area in the image.
-
#custom_metadata ⇒ Hash{Symbol=>Object}?
JSON key-value pairs to associate with the asset.
-
#description ⇒ String?
Optional text to describe the contents of the file.
-
#extensions ⇒ Array<Imagekitio::Models::ExtensionItem::RemoveBg, Imagekitio::Models::ExtensionItem::AIAutoDescription, Imagekitio::Models::ExtensionItem::AutoTaggingExtension>?
Array of extensions to be applied to the asset.
-
#file ⇒ Pathname, ...
The API accepts any of the following:.
-
#file_name ⇒ String
The name with which the file has to be uploaded.
-
#folder ⇒ String?
The folder path in which the image has to be uploaded.
-
#is_private_file ⇒ Boolean?
Whether to mark the file as private or not.
-
#is_published ⇒ Boolean?
Whether to upload file as published or not.
-
#overwrite_ai_tags ⇒ Boolean?
If set to ‘true` and a file already exists at the exact location, its AITags will be removed.
-
#overwrite_custom_metadata ⇒ Boolean?
If the request does not have ‘customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.
-
#overwrite_file ⇒ Boolean?
If ‘false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.
-
#overwrite_tags ⇒ Boolean?
If the request does not have ‘tags`, and a file already exists at the exact location, existing tags will be removed.
-
#response_fields ⇒ Array<Symbol, Imagekitio::Models::Beta::V2::FileUploadParams::ResponseField>?
Array of response field keys to include in the API response body.
-
#tags ⇒ Array<String>?
Set the tags while uploading the file.
-
#token ⇒ String?
This is the client-generated JSON Web Token (JWT).
-
#transformation ⇒ Imagekitio::Models::Beta::V2::FileUploadParams::Transformation?
Configure pre-processing (‘pre`) and post-processing (`post`) transformations.
-
#use_unique_file_name ⇒ Boolean?
Whether to use a unique filename for this file or not.
-
#webhook_url ⇒ String?
The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request.
Attributes included from Internal::Type::RequestParameters
Class Method Summary collapse
-
.dump_request(params) ⇒ Array(Object, Hash{Symbol=>Object})
private
Serialize upload options to handle proper formatting for ImageKit backend API.
- .serialize_upload_options(upload_options) ⇒ Hash{Symbol=>Object} private
- .values ⇒ Array<Symbol>
Methods included from Internal::Type::RequestParameters::Converter
Methods included from Internal::Type::RequestParameters
Methods inherited from Internal::Type::BaseModel
#==, ==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, #initialize, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml
Methods included from Internal::Type::Converter
#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
This class inherits a constructor from Imagekitio::Internal::Type::BaseModel
Instance Attribute Details
#checks ⇒ String?
Server-side checks to run on the asset. Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks).
117 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 117 optional :checks, String |
#custom_coordinates ⇒ String?
Define an important area in the image. This is only relevant for image type files.
-
To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format ‘x,y,width,height`. For example - `10,10,100,100`
-
Can be used with fo-customtransformation.
-
If this field is not specified and the file is overwritten, then customCoordinates will be removed.
131 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 131 optional :custom_coordinates, String, api_name: :customCoordinates |
#custom_metadata ⇒ Hash{Symbol=>Object}?
JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.
138 139 140 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 138 optional :custom_metadata, Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], api_name: :customMetadata |
#description ⇒ String?
Optional text to describe the contents of the file.
146 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 146 optional :description, String |
#extensions ⇒ Array<Imagekitio::Models::ExtensionItem::RemoveBg, Imagekitio::Models::ExtensionItem::AIAutoDescription, Imagekitio::Models::ExtensionItem::AutoTaggingExtension>?
Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.
153 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 153 optional :extensions, -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::ExtensionItem] } |
#file ⇒ Pathname, ...
The API accepts any of the following:
-
**Binary data** – send the raw bytes as ‘multipart/form-data`.
-
**HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
-
**Base64 string** – the file encoded as a Base64 data URI or plain Base64.
When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
86 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 86 required :file, Imagekitio::Internal::Type::FileInput |
#file_name ⇒ String
The name with which the file has to be uploaded.
92 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 92 required :file_name, String, api_name: :fileName |
#folder ⇒ String?
The folder path in which the image has to be uploaded. If the folder(s) didn’t exist before, a new folder(s) is created. Using multiple ‘/` creates a nested folder.
161 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 161 optional :folder, String |
#is_private_file ⇒ Boolean?
Whether to mark the file as private or not.
If ‘true`, the file is marked as private and is accessible only using named transformation or signed URL.
170 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 170 optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile |
#is_published ⇒ Boolean?
Whether to upload file as published or not.
If ‘false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.
The option to upload in draft state is only available in custom enterprise pricing plans.
183 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 183 optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished |
#overwrite_ai_tags ⇒ Boolean?
If set to ‘true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.
190 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 190 optional :overwrite_ai_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteAITags |
#overwrite_custom_metadata ⇒ Boolean?
If the request does not have ‘customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.
197 198 199 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 197 optional :overwrite_custom_metadata, Imagekitio::Internal::Type::Boolean, api_name: :overwriteCustomMetadata |
#overwrite_file ⇒ Boolean?
If ‘false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.
206 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 206 optional :overwrite_file, Imagekitio::Internal::Type::Boolean, api_name: :overwriteFile |
#overwrite_tags ⇒ Boolean?
If the request does not have ‘tags`, and a file already exists at the exact location, existing tags will be removed.
213 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 213 optional :overwrite_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteTags |
#response_fields ⇒ Array<Symbol, Imagekitio::Models::Beta::V2::FileUploadParams::ResponseField>?
Array of response field keys to include in the API response body.
219 220 221 222 223 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 219 optional :response_fields, -> { Imagekitio::Internal::Type::ArrayOf[enum: Imagekitio::Beta::V2::FileUploadParams::ResponseField] }, api_name: :responseFields |
#tags ⇒ Array<String>?
Set the tags while uploading the file. Provide an array of tag strings (e.g. ‘[“tag1”, “tag2”, “tag3”]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. If this field is not specified and the file is overwritten, the existing tags will be removed.
|
|
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 232
|
#token ⇒ String?
This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side.
Note: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token.
**⚠️Warning**: JWT must be generated on the server-side because it is generated using your account’s private API key. This field is required for authentication when uploading a file from the client-side.
110 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 110 optional :token, String |
#transformation ⇒ Imagekitio::Models::Beta::V2::FileUploadParams::Transformation?
Configure pre-processing (‘pre`) and post-processing (`post`) transformations.
-
‘pre` — applied before the file is uploaded to the Media Library. Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).
-
‘post` — applied immediately after upload. Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they’re ready for delivery without delay.
You can mix and match any combination of post-processing types.
248 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 248 optional :transformation, -> { Imagekitio::Beta::V2::FileUploadParams::Transformation } |
#use_unique_file_name ⇒ Boolean?
Whether to use a unique filename for this file or not.
If ‘true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.
If ‘false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.
260 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 260 optional :use_unique_file_name, Imagekitio::Internal::Type::Boolean, api_name: :useUniqueFileName |
#webhook_url ⇒ String?
The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.
269 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 269 optional :webhook_url, String, api_name: :webhookUrl |
Class Method Details
.dump_request(params) ⇒ Array(Object, Hash{Symbol=>Object})
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Serialize upload options to handle proper formatting for ImageKit backend API. Special cases handled:
-
tags: converted to comma-separated string
-
responseFields: converted to comma-separated string
-
extensions: JSON stringified
-
customMetadata: JSON stringified
-
transformation: JSON stringified
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 25 def self.dump_request(params) state = {can_retry: true} case (dumped = dump(params, state: state)) in Hash serialized = (dumped) = Imagekitio::Internal::Util.coerce_hash!(serialized[:request_options]).to_h = state.fetch(:can_retry) ? : {**, max_retries: 0} [serialized.except(:request_options), ] else [dumped, nil] end end |
.serialize_upload_options(upload_options) ⇒ Hash{Symbol=>Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 43 def self.() serialized = {} .each do |key, value| # Skip nil values if value.nil? serialized[key] = value next end serialized[key] = case key when :tags, :responseFields # Tags and response fields should be comma-separated strings value.is_a?(Array) ? value.join(",") : value when :extensions # Extensions should be JSON stringified value.is_a?(Array) ? JSON.generate(value) : value when :customMetadata # Custom metadata should be JSON stringified value.is_a?(Hash) ? JSON.generate(value) : value when :transformation # Transformation should be JSON stringified value.is_a?(Hash) || value.respond_to?(:to_h) ? JSON.generate(value) : value else value end end serialized end |
.values ⇒ Array<Symbol>
|
|
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 329
|