Class: Imagekitio::Resources::Files
- Inherits:
-
Object
- Object
- Imagekitio::Resources::Files
- Defined in:
- lib/imagekitio/resources/files.rb,
lib/imagekitio/resources/files/bulk.rb,
lib/imagekitio/resources/files/metadata.rb,
lib/imagekitio/resources/files/versions.rb
Defined Under Namespace
Classes: Bulk, Metadata, Versions
Instance Attribute Summary collapse
- #bulk ⇒ Imagekitio::Resources::Files::Bulk readonly
- #metadata ⇒ Imagekitio::Resources::Files::Metadata readonly
- #versions ⇒ Imagekitio::Resources::Files::Versions readonly
Instance Method Summary collapse
-
#copy(destination_path:, source_file_path:, include_file_versions: nil, request_options: {}) ⇒ Imagekitio::Models::FileCopyResponse
Some parameter documentations has been truncated, see Models::FileCopyParams for more details.
-
#delete(file_id, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::FileDeleteParams for more details.
-
#get(file_id, request_options: {}) ⇒ Imagekitio::Models::File
Some parameter documentations has been truncated, see Models::FileGetParams for more details.
-
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#move(destination_path:, source_file_path:, request_options: {}) ⇒ Imagekitio::Models::FileMoveResponse
Some parameter documentations has been truncated, see Models::FileMoveParams for more details.
-
#rename(file_path:, new_file_name:, purge_cache: nil, request_options: {}) ⇒ Imagekitio::Models::FileRenameResponse
Some parameter documentations has been truncated, see Models::FileRenameParams for more details.
-
#update(file_id, update_file_request:, request_options: {}) ⇒ Imagekitio::Models::FileUpdateResponse
Some parameter documentations has been truncated, see Models::FileUpdateParams for more details.
-
#upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) ⇒ Imagekitio::Models::FileUploadResponse
Some parameter documentations has been truncated, see Models::FileUploadParams for more details.
Constructor Details
#initialize(client:) ⇒ Files
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.
Returns a new instance of Files.
293 294 295 296 297 298 |
# File 'lib/imagekitio/resources/files.rb', line 293 def initialize(client:) @client = client @bulk = Imagekitio::Resources::Files::Bulk.new(client: client) @versions = Imagekitio::Resources::Files::Versions.new(client: client) @metadata = Imagekitio::Resources::Files::Metadata.new(client: client) end |
Instance Attribute Details
#bulk ⇒ Imagekitio::Resources::Files::Bulk (readonly)
7 8 9 |
# File 'lib/imagekitio/resources/files.rb', line 7 def bulk @bulk end |
#metadata ⇒ Imagekitio::Resources::Files::Metadata (readonly)
13 14 15 |
# File 'lib/imagekitio/resources/files.rb', line 13 def @metadata end |
#versions ⇒ Imagekitio::Resources::Files::Versions (readonly)
10 11 12 |
# File 'lib/imagekitio/resources/files.rb', line 10 def versions @versions end |
Instance Method Details
#copy(destination_path:, source_file_path:, include_file_versions: nil, request_options: {}) ⇒ Imagekitio::Models::FileCopyResponse
Some parameter documentations has been truncated, see Models::FileCopyParams for more details.
This will copy a file from one folder to another.
Note: If any file at the destination has the same name as the source file, then the source file and its versions (if ‘includeFileVersions` is set to true) will be appended to the destination file version history.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/imagekitio/resources/files.rb', line 93 def copy(params) parsed, = Imagekitio::FileCopyParams.dump_request(params) @client.request( method: :post, path: "v1/files/copy", body: parsed, model: Imagekitio::Models::FileCopyResponse, options: ) end |
#delete(file_id, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::FileDeleteParams for more details.
This API deletes the file and all its file versions permanently.
Note: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.
62 63 64 65 66 67 68 69 |
# File 'lib/imagekitio/resources/files.rb', line 62 def delete(file_id, params = {}) @client.request( method: :delete, path: ["v1/files/%1$s", file_id], model: NilClass, options: params[:request_options] ) end |
#get(file_id, request_options: {}) ⇒ Imagekitio::Models::File
Some parameter documentations has been truncated, see Models::FileGetParams for more details.
This API returns an object with details or attributes about the current version of the file.
119 120 121 122 123 124 125 126 |
# File 'lib/imagekitio/resources/files.rb', line 119 def get(file_id, params = {}) @client.request( method: :get, path: ["v1/files/%1$s/details", file_id], model: Imagekitio::File, options: params[:request_options] ) end |
#move(destination_path:, source_file_path:, request_options: {}) ⇒ Imagekitio::Models::FileMoveResponse
Some parameter documentations has been truncated, see Models::FileMoveParams for more details.
This will move a file and all its versions from one folder to another.
Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/imagekitio/resources/files.rb', line 147 def move(params) parsed, = Imagekitio::FileMoveParams.dump_request(params) @client.request( method: :post, path: "v1/files/move", body: parsed, model: Imagekitio::Models::FileMoveResponse, options: ) end |
#rename(file_path:, new_file_name:, purge_cache: nil, request_options: {}) ⇒ Imagekitio::Models::FileRenameResponse
Some parameter documentations has been truncated, see Models::FileRenameParams for more details.
You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file.
Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.
180 181 182 183 184 185 186 187 188 189 |
# File 'lib/imagekitio/resources/files.rb', line 180 def rename(params) parsed, = Imagekitio::FileRenameParams.dump_request(params) @client.request( method: :put, path: "v1/files/rename", body: parsed, model: Imagekitio::Models::FileRenameResponse, options: ) end |
#update(file_id, update_file_request:, request_options: {}) ⇒ Imagekitio::Models::FileUpdateResponse
Some parameter documentations has been truncated, see Models::FileUpdateParams for more details.
This API updates the details or attributes of the current version of the file. You can update ‘tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and apply extensions using this API.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/imagekitio/resources/files.rb', line 33 def update(file_id, params) parsed, = Imagekitio::FileUpdateParams.dump_request(params) @client.request( method: :patch, path: ["v1/files/%1$s/details", file_id], body: parsed[:update_file_request], model: Imagekitio::Models::FileUpdateResponse, options: ) end |
#upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) ⇒ Imagekitio::Models::FileUploadResponse
Some parameter documentations has been truncated, see Models::FileUploadParams for more details.
ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time ‘token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.
The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.
**File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.
**Version limit** \ A file can have a maximum of 100 versions.
**Demo applications**
-
A full-fledged [upload widget using Uppy](github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.
-
[Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.
276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/imagekitio/resources/files.rb', line 276 def upload(params) parsed, = Imagekitio::FileUploadParams.dump_request(params) path = @client.base_url_overridden? ? "api/v1/files/upload" : "https://upload.imagekit.io/api/v1/files/upload" @client.request( method: :post, path: path, headers: {"content-type" => "multipart/form-data"}, body: parsed, model: Imagekitio::Models::FileUploadResponse, options: ) end |