Class: Imagekitio::Models::Beta::V2::FileUploadParams

Inherits:
Internal::Type::BaseModel show all
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

Attributes included from Internal::Type::RequestParameters

#request_options

Class Method Summary collapse

Methods included from Internal::Type::RequestParameters::Converter

dump_request

Methods included from Internal::Type::RequestParameters

included

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

#checksString?

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).

Returns:

  • (String, nil)


117
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 117

optional :checks, String

#custom_coordinatesString?

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.

Returns:

  • (String, nil)


131
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 131

optional :custom_coordinates, String, api_name: :customCoordinates

#custom_metadataHash{Symbol=>Object}?

JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.

Returns:

  • (Hash{Symbol=>Object}, nil)


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

#descriptionString?

Optional text to describe the contents of the file.

Returns:

  • (String, nil)


146
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 146

optional :description, String

#extensionsArray<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] }

#filePathname, ...

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.

Returns:



86
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 86

required :file, Imagekitio::Internal::Type::FileInput

#file_nameString

The name with which the file has to be uploaded.

Returns:

  • (String)


92
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 92

required :file_name, String, api_name: :fileName

#folderString?

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.

Returns:

  • (String, nil)


161
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 161

optional :folder, String

#is_private_fileBoolean?

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.

Returns:

  • (Boolean, nil)


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_publishedBoolean?

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.

Returns:

  • (Boolean, nil)


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_tagsBoolean?

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.

Returns:

  • (Boolean, nil)


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_metadataBoolean?

If the request does not have ‘customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.

Returns:

  • (Boolean, nil)


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_fileBoolean?

If ‘false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.

Returns:

  • (Boolean, nil)


206
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 206

optional :overwrite_file, Imagekitio::Internal::Type::Boolean, api_name: :overwriteFile

#overwrite_tagsBoolean?

If the request does not have ‘tags`, and a file already exists at the exact location, existing tags will be removed.

Returns:

  • (Boolean, nil)


213
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 213

optional :overwrite_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteTags

#response_fieldsArray<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

#tagsArray<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.

Returns:

  • (Array<String>, nil)


# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 232

#tokenString?

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.

Returns:

  • (String, nil)


110
# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 110

optional :token, String

#transformationImagekitio::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_nameBoolean?

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.

Returns:

  • (Boolean, nil)


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_urlString?

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.

Returns:

  • (String, nil)


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

Parameters:

  • params (Object)

Returns:

  • (Array(Object, Hash{Symbol=>Object}))


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 = serialize_upload_options(dumped)
    options = Imagekitio::Internal::Util.coerce_hash!(serialized[:request_options]).to_h
    request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0}
    [serialized.except(:request_options), 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.

Parameters:

  • upload_options (Hash{Symbol=>Object})

Returns:

  • (Hash{Symbol=>Object})


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.serialize_upload_options(upload_options)
  serialized = {}

  upload_options.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

.valuesArray<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/imagekitio/models/beta/v2/file_upload_params.rb', line 329