imagekitio 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ignore +2 -0
- data/CHANGELOG.md +116 -0
- data/README.md +538 -679
- data/SECURITY.md +27 -0
- data/lib/imagekitio/client.rb +122 -195
- data/lib/imagekitio/errors.rb +226 -2
- data/lib/imagekitio/file_part.rb +58 -0
- data/lib/imagekitio/helpers/crypto_utils.rb +25 -0
- data/lib/imagekitio/helpers/helper.rb +689 -0
- data/lib/imagekitio/helpers/transformation_utils.rb +164 -0
- data/lib/imagekitio/helpers/uuid_utils.rb +18 -0
- data/lib/imagekitio/internal/transport/base_client.rb +567 -0
- data/lib/imagekitio/internal/transport/pooled_net_requester.rb +217 -0
- data/lib/imagekitio/internal/type/array_of.rb +168 -0
- data/lib/imagekitio/internal/type/base_model.rb +530 -0
- data/lib/imagekitio/internal/type/base_page.rb +55 -0
- data/lib/imagekitio/internal/type/boolean.rb +77 -0
- data/lib/imagekitio/internal/type/converter.rb +327 -0
- data/lib/imagekitio/internal/type/enum.rb +156 -0
- data/lib/imagekitio/internal/type/file_input.rb +111 -0
- data/lib/imagekitio/internal/type/hash_of.rb +188 -0
- data/lib/imagekitio/internal/type/request_parameters.rb +42 -0
- data/lib/imagekitio/internal/type/union.rb +250 -0
- data/lib/imagekitio/internal/type/unknown.rb +81 -0
- data/lib/imagekitio/internal/util.rb +915 -0
- data/lib/imagekitio/internal.rb +20 -0
- data/lib/imagekitio/models/accounts/origin_create_params.rb +24 -0
- data/lib/imagekitio/models/accounts/origin_delete_params.rb +16 -0
- data/lib/imagekitio/models/accounts/origin_get_params.rb +16 -0
- data/lib/imagekitio/models/accounts/origin_list_params.rb +16 -0
- data/lib/imagekitio/models/accounts/origin_list_response.rb +11 -0
- data/lib/imagekitio/models/accounts/origin_request.rb +547 -0
- data/lib/imagekitio/models/accounts/origin_response.rb +568 -0
- data/lib/imagekitio/models/accounts/origin_update_params.rb +24 -0
- data/lib/imagekitio/models/accounts/url_endpoint_create_params.rb +16 -0
- data/lib/imagekitio/models/accounts/url_endpoint_delete_params.rb +16 -0
- data/lib/imagekitio/models/accounts/url_endpoint_get_params.rb +16 -0
- data/lib/imagekitio/models/accounts/url_endpoint_list_params.rb +16 -0
- data/lib/imagekitio/models/accounts/url_endpoint_list_response.rb +11 -0
- data/lib/imagekitio/models/accounts/url_endpoint_request.rb +110 -0
- data/lib/imagekitio/models/accounts/url_endpoint_response.rb +123 -0
- data/lib/imagekitio/models/accounts/url_endpoint_update_params.rb +16 -0
- data/lib/imagekitio/models/accounts/usage_get_params.rb +37 -0
- data/lib/imagekitio/models/accounts/usage_get_response.rb +51 -0
- data/lib/imagekitio/models/asset_list_params.rb +158 -0
- data/lib/imagekitio/models/asset_list_response.rb +24 -0
- data/lib/imagekitio/models/base_overlay.rb +21 -0
- data/lib/imagekitio/models/base_webhook_event.rb +24 -0
- data/lib/imagekitio/models/beta/v2/file_upload_params.rb +510 -0
- data/lib/imagekitio/models/beta/v2/file_upload_response.rb +618 -0
- data/lib/imagekitio/models/cache/invalidation_create_params.rb +27 -0
- data/lib/imagekitio/models/cache/invalidation_create_response.rb +23 -0
- data/lib/imagekitio/models/cache/invalidation_get_params.rb +16 -0
- data/lib/imagekitio/models/cache/invalidation_get_response.rb +35 -0
- data/lib/imagekitio/models/custom_metadata_field.rb +243 -0
- data/lib/imagekitio/models/custom_metadata_field_create_params.rb +238 -0
- data/lib/imagekitio/models/custom_metadata_field_delete_params.rb +14 -0
- data/lib/imagekitio/models/custom_metadata_field_delete_response.rb +10 -0
- data/lib/imagekitio/models/custom_metadata_field_list_params.rb +36 -0
- data/lib/imagekitio/models/custom_metadata_field_list_response.rb +9 -0
- data/lib/imagekitio/models/custom_metadata_field_update_params.rb +212 -0
- data/lib/imagekitio/models/extensions.rb +136 -0
- data/lib/imagekitio/models/file.rb +497 -0
- data/lib/imagekitio/models/file_copy_params.rb +43 -0
- data/lib/imagekitio/models/file_copy_response.rb +10 -0
- data/lib/imagekitio/models/file_delete_params.rb +14 -0
- data/lib/imagekitio/models/file_get_params.rb +14 -0
- data/lib/imagekitio/models/file_move_params.rb +33 -0
- data/lib/imagekitio/models/file_move_response.rb +10 -0
- data/lib/imagekitio/models/file_rename_params.rb +61 -0
- data/lib/imagekitio/models/file_rename_response.rb +21 -0
- data/lib/imagekitio/models/file_update_params.rb +22 -0
- data/lib/imagekitio/models/file_update_response.rb +104 -0
- data/lib/imagekitio/models/file_upload_params.rb +540 -0
- data/lib/imagekitio/models/file_upload_response.rb +611 -0
- data/lib/imagekitio/models/files/bulk_add_tags_params.rb +35 -0
- data/lib/imagekitio/models/files/bulk_add_tags_response.rb +24 -0
- data/lib/imagekitio/models/files/bulk_delete_params.rb +27 -0
- data/lib/imagekitio/models/files/bulk_delete_response.rb +24 -0
- data/lib/imagekitio/models/files/bulk_remove_ai_tags_params.rb +35 -0
- data/lib/imagekitio/models/files/bulk_remove_ai_tags_response.rb +24 -0
- data/lib/imagekitio/models/files/bulk_remove_tags_params.rb +35 -0
- data/lib/imagekitio/models/files/bulk_remove_tags_response.rb +24 -0
- data/lib/imagekitio/models/files/metadata_get_from_url_params.rb +28 -0
- data/lib/imagekitio/models/files/metadata_get_params.rb +16 -0
- data/lib/imagekitio/models/files/version_delete_params.rb +22 -0
- data/lib/imagekitio/models/files/version_delete_response.rb +12 -0
- data/lib/imagekitio/models/files/version_get_params.rb +22 -0
- data/lib/imagekitio/models/files/version_list_params.rb +16 -0
- data/lib/imagekitio/models/files/version_list_response.rb +10 -0
- data/lib/imagekitio/models/files/version_restore_params.rb +22 -0
- data/lib/imagekitio/models/folder.rb +76 -0
- data/lib/imagekitio/models/folder_copy_params.rb +44 -0
- data/lib/imagekitio/models/folder_copy_response.rb +23 -0
- data/lib/imagekitio/models/folder_create_params.rb +43 -0
- data/lib/imagekitio/models/folder_create_response.rb +10 -0
- data/lib/imagekitio/models/folder_delete_params.rb +25 -0
- data/lib/imagekitio/models/folder_delete_response.rb +10 -0
- data/lib/imagekitio/models/folder_move_params.rb +34 -0
- data/lib/imagekitio/models/folder_move_response.rb +23 -0
- data/lib/imagekitio/models/folder_rename_params.rb +59 -0
- data/lib/imagekitio/models/folder_rename_response.rb +23 -0
- data/lib/imagekitio/models/folders/job_get_params.rb +16 -0
- data/lib/imagekitio/models/folders/job_get_response.rb +74 -0
- data/lib/imagekitio/models/get_image_attributes_options.rb +68 -0
- data/lib/imagekitio/models/image_overlay.rb +66 -0
- data/lib/imagekitio/models/metadata.rb +483 -0
- data/lib/imagekitio/models/overlay.rb +28 -0
- data/lib/imagekitio/models/overlay_position.rb +101 -0
- data/lib/imagekitio/models/overlay_timing.rb +97 -0
- data/lib/imagekitio/models/responsive_image_attributes.rb +48 -0
- data/lib/imagekitio/models/solid_color_overlay.rb +42 -0
- data/lib/imagekitio/models/solid_color_overlay_transformation.rb +135 -0
- data/lib/imagekitio/models/src_options.rb +96 -0
- data/lib/imagekitio/models/streaming_resolution.rb +22 -0
- data/lib/imagekitio/models/subtitle_overlay.rb +64 -0
- data/lib/imagekitio/models/subtitle_overlay_transformation.rb +113 -0
- data/lib/imagekitio/models/text_overlay.rb +65 -0
- data/lib/imagekitio/models/text_overlay_transformation.rb +267 -0
- data/lib/imagekitio/models/transformation.rb +1100 -0
- data/lib/imagekitio/models/transformation_position.rb +19 -0
- data/lib/imagekitio/models/unsafe_unwrap_webhook_event.rb +36 -0
- data/lib/imagekitio/models/unwrap_webhook_event.rb +36 -0
- data/lib/imagekitio/models/update_file_request.rb +164 -0
- data/lib/imagekitio/models/upload_post_transform_error_event.rb +180 -0
- data/lib/imagekitio/models/upload_post_transform_success_event.rb +143 -0
- data/lib/imagekitio/models/upload_pre_transform_error_event.rb +108 -0
- data/lib/imagekitio/models/upload_pre_transform_success_event.rb +690 -0
- data/lib/imagekitio/models/video_overlay.rb +64 -0
- data/lib/imagekitio/models/video_transformation_accepted_event.rb +279 -0
- data/lib/imagekitio/models/video_transformation_error_event.rb +326 -0
- data/lib/imagekitio/models/video_transformation_ready_event.rb +379 -0
- data/lib/imagekitio/models/webhook_unsafe_unwrap_params.rb +14 -0
- data/lib/imagekitio/models/webhook_unwrap_params.rb +14 -0
- data/lib/imagekitio/models.rb +160 -0
- data/lib/imagekitio/request_options.rb +77 -0
- data/lib/imagekitio/resources/accounts/origins.rb +145 -0
- data/lib/imagekitio/resources/accounts/url_endpoints.rb +151 -0
- data/lib/imagekitio/resources/accounts/usage.rb +46 -0
- data/lib/imagekitio/resources/accounts.rb +26 -0
- data/lib/imagekitio/resources/assets.rb +54 -0
- data/lib/imagekitio/resources/beta/v2/files.rb +110 -0
- data/lib/imagekitio/resources/beta/v2.rb +20 -0
- data/lib/imagekitio/resources/beta.rb +18 -0
- data/lib/imagekitio/resources/cache/invalidation.rb +66 -0
- data/lib/imagekitio/resources/cache.rb +18 -0
- data/lib/imagekitio/resources/custom_metadata_fields.rb +133 -0
- data/lib/imagekitio/resources/files/bulk.rb +131 -0
- data/lib/imagekitio/resources/files/metadata.rb +69 -0
- data/lib/imagekitio/resources/files/versions.rb +132 -0
- data/lib/imagekitio/resources/files.rb +305 -0
- data/lib/imagekitio/resources/folders/job.rb +39 -0
- data/lib/imagekitio/resources/folders.rb +166 -0
- data/lib/imagekitio/resources/webhooks.rb +30 -0
- data/lib/imagekitio/version.rb +5 -0
- data/lib/imagekitio.rb +181 -13
- data/manifest.yaml +15 -0
- data/rbi/imagekitio/client.rbi +92 -0
- data/rbi/imagekitio/errors.rbi +205 -0
- data/rbi/imagekitio/file_part.rbi +37 -0
- data/rbi/imagekitio/helpers/helper.rbi +41 -0
- data/rbi/imagekitio/internal/transport/base_client.rbi +295 -0
- data/rbi/imagekitio/internal/transport/pooled_net_requester.rbi +80 -0
- data/rbi/imagekitio/internal/type/array_of.rbi +104 -0
- data/rbi/imagekitio/internal/type/base_model.rbi +304 -0
- data/rbi/imagekitio/internal/type/base_page.rbi +42 -0
- data/rbi/imagekitio/internal/type/boolean.rbi +58 -0
- data/rbi/imagekitio/internal/type/converter.rbi +216 -0
- data/rbi/imagekitio/internal/type/enum.rbi +82 -0
- data/rbi/imagekitio/internal/type/file_input.rbi +59 -0
- data/rbi/imagekitio/internal/type/hash_of.rbi +104 -0
- data/rbi/imagekitio/internal/type/request_parameters.rbi +29 -0
- data/rbi/imagekitio/internal/type/union.rbi +128 -0
- data/rbi/imagekitio/internal/type/unknown.rbi +58 -0
- data/rbi/imagekitio/internal/util.rbi +487 -0
- data/rbi/imagekitio/internal.rbi +18 -0
- data/rbi/imagekitio/models/accounts/origin_create_params.rbi +81 -0
- data/rbi/imagekitio/models/accounts/origin_delete_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/origin_get_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/origin_list_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/origin_list_response.rbi +15 -0
- data/rbi/imagekitio/models/accounts/origin_request.rbi +775 -0
- data/rbi/imagekitio/models/accounts/origin_response.rbi +718 -0
- data/rbi/imagekitio/models/accounts/origin_update_params.rbi +81 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_create_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_delete_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_get_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_list_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_list_response.rbi +15 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_request.rbi +218 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_response.rbi +213 -0
- data/rbi/imagekitio/models/accounts/url_endpoint_update_params.rbi +34 -0
- data/rbi/imagekitio/models/accounts/usage_get_params.rbi +60 -0
- data/rbi/imagekitio/models/accounts/usage_get_response.rbi +89 -0
- data/rbi/imagekitio/models/asset_list_params.rbi +281 -0
- data/rbi/imagekitio/models/asset_list_response.rbi +28 -0
- data/rbi/imagekitio/models/base_overlay.rbi +44 -0
- data/rbi/imagekitio/models/base_webhook_event.rbi +33 -0
- data/rbi/imagekitio/models/beta/v2/file_upload_params.rbi +861 -0
- data/rbi/imagekitio/models/beta/v2/file_upload_response.rbi +1197 -0
- data/rbi/imagekitio/models/cache/invalidation_create_params.rbi +45 -0
- data/rbi/imagekitio/models/cache/invalidation_create_response.rbi +37 -0
- data/rbi/imagekitio/models/cache/invalidation_get_params.rbi +34 -0
- data/rbi/imagekitio/models/cache/invalidation_get_response.rbi +93 -0
- data/rbi/imagekitio/models/custom_metadata_field.rbi +422 -0
- data/rbi/imagekitio/models/custom_metadata_field_create_params.rbi +443 -0
- data/rbi/imagekitio/models/custom_metadata_field_delete_params.rbi +30 -0
- data/rbi/imagekitio/models/custom_metadata_field_delete_response.rbi +23 -0
- data/rbi/imagekitio/models/custom_metadata_field_list_params.rbi +66 -0
- data/rbi/imagekitio/models/custom_metadata_field_list_response.rbi +11 -0
- data/rbi/imagekitio/models/custom_metadata_field_update_params.rbi +376 -0
- data/rbi/imagekitio/models/extensions.rbi +274 -0
- data/rbi/imagekitio/models/file.rbi +789 -0
- data/rbi/imagekitio/models/file_copy_params.rbi +66 -0
- data/rbi/imagekitio/models/file_copy_response.rbi +23 -0
- data/rbi/imagekitio/models/file_delete_params.rbi +27 -0
- data/rbi/imagekitio/models/file_get_params.rbi +27 -0
- data/rbi/imagekitio/models/file_move_params.rbi +51 -0
- data/rbi/imagekitio/models/file_move_response.rbi +23 -0
- data/rbi/imagekitio/models/file_rename_params.rbi +102 -0
- data/rbi/imagekitio/models/file_rename_response.rbi +35 -0
- data/rbi/imagekitio/models/file_update_params.rbi +58 -0
- data/rbi/imagekitio/models/file_update_response.rbi +322 -0
- data/rbi/imagekitio/models/file_upload_params.rbi +897 -0
- data/rbi/imagekitio/models/file_upload_response.rbi +1176 -0
- data/rbi/imagekitio/models/files/bulk_add_tags_params.rbi +56 -0
- data/rbi/imagekitio/models/files/bulk_add_tags_response.rbi +41 -0
- data/rbi/imagekitio/models/files/bulk_delete_params.rbi +48 -0
- data/rbi/imagekitio/models/files/bulk_delete_response.rbi +41 -0
- data/rbi/imagekitio/models/files/bulk_remove_ai_tags_params.rbi +56 -0
- data/rbi/imagekitio/models/files/bulk_remove_ai_tags_response.rbi +41 -0
- data/rbi/imagekitio/models/files/bulk_remove_tags_params.rbi +56 -0
- data/rbi/imagekitio/models/files/bulk_remove_tags_response.rbi +41 -0
- data/rbi/imagekitio/models/files/metadata_get_from_url_params.rbi +47 -0
- data/rbi/imagekitio/models/files/metadata_get_params.rbi +34 -0
- data/rbi/imagekitio/models/files/version_delete_params.rbi +40 -0
- data/rbi/imagekitio/models/files/version_delete_response.rbi +25 -0
- data/rbi/imagekitio/models/files/version_get_params.rbi +40 -0
- data/rbi/imagekitio/models/files/version_list_params.rbi +34 -0
- data/rbi/imagekitio/models/files/version_list_response.rbi +13 -0
- data/rbi/imagekitio/models/files/version_restore_params.rbi +40 -0
- data/rbi/imagekitio/models/folder.rbi +121 -0
- data/rbi/imagekitio/models/folder_copy_params.rbi +68 -0
- data/rbi/imagekitio/models/folder_copy_response.rbi +33 -0
- data/rbi/imagekitio/models/folder_create_params.rbi +71 -0
- data/rbi/imagekitio/models/folder_create_response.rbi +23 -0
- data/rbi/imagekitio/models/folder_delete_params.rbi +40 -0
- data/rbi/imagekitio/models/folder_delete_response.rbi +23 -0
- data/rbi/imagekitio/models/folder_move_params.rbi +53 -0
- data/rbi/imagekitio/models/folder_move_response.rbi +33 -0
- data/rbi/imagekitio/models/folder_rename_params.rbi +98 -0
- data/rbi/imagekitio/models/folder_rename_response.rbi +33 -0
- data/rbi/imagekitio/models/folders/job_get_params.rbi +34 -0
- data/rbi/imagekitio/models/folders/job_get_response.rbi +173 -0
- data/rbi/imagekitio/models/get_image_attributes_options.rbi +121 -0
- data/rbi/imagekitio/models/image_overlay.rbi +109 -0
- data/rbi/imagekitio/models/metadata.rbi +813 -0
- data/rbi/imagekitio/models/overlay.rbi +28 -0
- data/rbi/imagekitio/models/overlay_position.rbi +148 -0
- data/rbi/imagekitio/models/overlay_timing.rbi +135 -0
- data/rbi/imagekitio/models/responsive_image_attributes.rbi +74 -0
- data/rbi/imagekitio/models/solid_color_overlay.rbi +79 -0
- data/rbi/imagekitio/models/solid_color_overlay_transformation.rbi +218 -0
- data/rbi/imagekitio/models/src_options.rbi +159 -0
- data/rbi/imagekitio/models/streaming_resolution.rbi +38 -0
- data/rbi/imagekitio/models/subtitle_overlay.rbi +114 -0
- data/rbi/imagekitio/models/subtitle_overlay_transformation.rbi +215 -0
- data/rbi/imagekitio/models/text_overlay.rbi +110 -0
- data/rbi/imagekitio/models/text_overlay_transformation.rbi +451 -0
- data/rbi/imagekitio/models/transformation.rbi +1646 -0
- data/rbi/imagekitio/models/transformation_position.rbi +28 -0
- data/rbi/imagekitio/models/unsafe_unwrap_webhook_event.rbi +33 -0
- data/rbi/imagekitio/models/unwrap_webhook_event.rbi +31 -0
- data/rbi/imagekitio/models/update_file_request.rbi +316 -0
- data/rbi/imagekitio/models/upload_post_transform_error_event.rbi +434 -0
- data/rbi/imagekitio/models/upload_post_transform_success_event.rbi +327 -0
- data/rbi/imagekitio/models/upload_pre_transform_error_event.rbi +244 -0
- data/rbi/imagekitio/models/upload_pre_transform_success_event.rbi +1300 -0
- data/rbi/imagekitio/models/video_overlay.rbi +105 -0
- data/rbi/imagekitio/models/video_transformation_accepted_event.rbi +659 -0
- data/rbi/imagekitio/models/video_transformation_error_event.rbi +772 -0
- data/rbi/imagekitio/models/video_transformation_ready_event.rbi +864 -0
- data/rbi/imagekitio/models/webhook_unsafe_unwrap_params.rbi +30 -0
- data/rbi/imagekitio/models/webhook_unwrap_params.rbi +27 -0
- data/rbi/imagekitio/models.rbi +135 -0
- data/rbi/imagekitio/request_options.rbi +59 -0
- data/rbi/imagekitio/resources/accounts/origins.rbi +91 -0
- data/rbi/imagekitio/resources/accounts/url_endpoints.rbi +129 -0
- data/rbi/imagekitio/resources/accounts/usage.rbi +36 -0
- data/rbi/imagekitio/resources/accounts.rbi +21 -0
- data/rbi/imagekitio/resources/assets.rbi +74 -0
- data/rbi/imagekitio/resources/beta/v2/files.rbi +193 -0
- data/rbi/imagekitio/resources/beta/v2.rbi +17 -0
- data/rbi/imagekitio/resources/beta.rbi +15 -0
- data/rbi/imagekitio/resources/cache/invalidation.rbi +44 -0
- data/rbi/imagekitio/resources/cache.rbi +15 -0
- data/rbi/imagekitio/resources/custom_metadata_fields.rbi +106 -0
- data/rbi/imagekitio/resources/files/bulk.rbi +88 -0
- data/rbi/imagekitio/resources/files/metadata.rbi +49 -0
- data/rbi/imagekitio/resources/files/versions.rbi +89 -0
- data/rbi/imagekitio/resources/files.rbi +364 -0
- data/rbi/imagekitio/resources/folders/job.rbi +29 -0
- data/rbi/imagekitio/resources/folders.rbi +146 -0
- data/rbi/imagekitio/resources/webhooks.rbi +50 -0
- data/rbi/imagekitio/version.rbi +5 -0
- data/sig/imagekitio/client.rbs +47 -0
- data/sig/imagekitio/errors.rbs +117 -0
- data/sig/imagekitio/file_part.rbs +21 -0
- data/sig/imagekitio/helpers/helper.rbs +24 -0
- data/sig/imagekitio/internal/transport/base_client.rbs +131 -0
- data/sig/imagekitio/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/imagekitio/internal/type/array_of.rbs +48 -0
- data/sig/imagekitio/internal/type/base_model.rbs +102 -0
- data/sig/imagekitio/internal/type/base_page.rbs +24 -0
- data/sig/imagekitio/internal/type/boolean.rbs +26 -0
- data/sig/imagekitio/internal/type/converter.rbs +79 -0
- data/sig/imagekitio/internal/type/enum.rbs +32 -0
- data/sig/imagekitio/internal/type/file_input.rbs +25 -0
- data/sig/imagekitio/internal/type/hash_of.rbs +48 -0
- data/sig/imagekitio/internal/type/request_parameters.rbs +19 -0
- data/sig/imagekitio/internal/type/union.rbs +52 -0
- data/sig/imagekitio/internal/type/unknown.rbs +26 -0
- data/sig/imagekitio/internal/util.rbs +185 -0
- data/sig/imagekitio/internal.rbs +9 -0
- data/sig/imagekitio/models/accounts/origin_create_params.rbs +30 -0
- data/sig/imagekitio/models/accounts/origin_delete_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/origin_get_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/origin_list_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/origin_list_response.rbs +10 -0
- data/sig/imagekitio/models/accounts/origin_request.rbs +468 -0
- data/sig/imagekitio/models/accounts/origin_response.rbs +418 -0
- data/sig/imagekitio/models/accounts/origin_update_params.rbs +30 -0
- data/sig/imagekitio/models/accounts/url_endpoint_create_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/url_endpoint_delete_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/url_endpoint_get_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/url_endpoint_list_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/url_endpoint_list_response.rbs +10 -0
- data/sig/imagekitio/models/accounts/url_endpoint_request.rbs +97 -0
- data/sig/imagekitio/models/accounts/url_endpoint_response.rbs +96 -0
- data/sig/imagekitio/models/accounts/url_endpoint_update_params.rbs +17 -0
- data/sig/imagekitio/models/accounts/usage_get_params.rbs +30 -0
- data/sig/imagekitio/models/accounts/usage_get_response.rbs +52 -0
- data/sig/imagekitio/models/asset_list_params.rbs +138 -0
- data/sig/imagekitio/models/asset_list_response.rbs +16 -0
- data/sig/imagekitio/models/base_overlay.rbs +31 -0
- data/sig/imagekitio/models/base_webhook_event.rbs +15 -0
- data/sig/imagekitio/models/beta/v2/file_upload_params.rbs +310 -0
- data/sig/imagekitio/models/beta/v2/file_upload_response.rbs +487 -0
- data/sig/imagekitio/models/cache/invalidation_create_params.rbs +25 -0
- data/sig/imagekitio/models/cache/invalidation_create_response.rbs +17 -0
- data/sig/imagekitio/models/cache/invalidation_get_params.rbs +17 -0
- data/sig/imagekitio/models/cache/invalidation_get_response.rbs +35 -0
- data/sig/imagekitio/models/custom_metadata_field.rbs +178 -0
- data/sig/imagekitio/models/custom_metadata_field_create_params.rbs +179 -0
- data/sig/imagekitio/models/custom_metadata_field_delete_params.rbs +15 -0
- data/sig/imagekitio/models/custom_metadata_field_delete_response.rbs +11 -0
- data/sig/imagekitio/models/custom_metadata_field_list_params.rbs +32 -0
- data/sig/imagekitio/models/custom_metadata_field_list_response.rbs +8 -0
- data/sig/imagekitio/models/custom_metadata_field_update_params.rbs +152 -0
- data/sig/imagekitio/models/extensions.rbs +132 -0
- data/sig/imagekitio/models/file.rbs +384 -0
- data/sig/imagekitio/models/file_copy_params.rbs +38 -0
- data/sig/imagekitio/models/file_copy_response.rbs +11 -0
- data/sig/imagekitio/models/file_delete_params.rbs +15 -0
- data/sig/imagekitio/models/file_get_params.rbs +14 -0
- data/sig/imagekitio/models/file_move_params.rbs +28 -0
- data/sig/imagekitio/models/file_move_response.rbs +11 -0
- data/sig/imagekitio/models/file_rename_params.rbs +34 -0
- data/sig/imagekitio/models/file_rename_response.rbs +15 -0
- data/sig/imagekitio/models/file_update_params.rbs +28 -0
- data/sig/imagekitio/models/file_update_response.rbs +120 -0
- data/sig/imagekitio/models/file_upload_params.rbs +327 -0
- data/sig/imagekitio/models/file_upload_response.rbs +483 -0
- data/sig/imagekitio/models/files/bulk_add_tags_params.rbs +30 -0
- data/sig/imagekitio/models/files/bulk_add_tags_response.rbs +20 -0
- data/sig/imagekitio/models/files/bulk_delete_params.rbs +26 -0
- data/sig/imagekitio/models/files/bulk_delete_response.rbs +20 -0
- data/sig/imagekitio/models/files/bulk_remove_ai_tags_params.rbs +30 -0
- data/sig/imagekitio/models/files/bulk_remove_ai_tags_response.rbs +20 -0
- data/sig/imagekitio/models/files/bulk_remove_tags_params.rbs +30 -0
- data/sig/imagekitio/models/files/bulk_remove_tags_response.rbs +20 -0
- data/sig/imagekitio/models/files/metadata_get_from_url_params.rbs +25 -0
- data/sig/imagekitio/models/files/metadata_get_params.rbs +17 -0
- data/sig/imagekitio/models/files/version_delete_params.rbs +25 -0
- data/sig/imagekitio/models/files/version_delete_response.rbs +13 -0
- data/sig/imagekitio/models/files/version_get_params.rbs +25 -0
- data/sig/imagekitio/models/files/version_list_params.rbs +17 -0
- data/sig/imagekitio/models/files/version_list_response.rbs +9 -0
- data/sig/imagekitio/models/files/version_restore_params.rbs +25 -0
- data/sig/imagekitio/models/folder.rbs +69 -0
- data/sig/imagekitio/models/folder_copy_params.rbs +38 -0
- data/sig/imagekitio/models/folder_copy_response.rbs +13 -0
- data/sig/imagekitio/models/folder_create_params.rbs +28 -0
- data/sig/imagekitio/models/folder_create_response.rbs +11 -0
- data/sig/imagekitio/models/folder_delete_params.rbs +23 -0
- data/sig/imagekitio/models/folder_delete_response.rbs +11 -0
- data/sig/imagekitio/models/folder_move_params.rbs +28 -0
- data/sig/imagekitio/models/folder_move_response.rbs +13 -0
- data/sig/imagekitio/models/folder_rename_params.rbs +34 -0
- data/sig/imagekitio/models/folder_rename_response.rbs +13 -0
- data/sig/imagekitio/models/folders/job_get_params.rbs +17 -0
- data/sig/imagekitio/models/folders/job_get_response.rbs +72 -0
- data/sig/imagekitio/models/get_image_attributes_options.rbs +43 -0
- data/sig/imagekitio/models/image_overlay.rbs +59 -0
- data/sig/imagekitio/models/metadata.rbs +546 -0
- data/sig/imagekitio/models/overlay.rbs +16 -0
- data/sig/imagekitio/models/overlay_position.rbs +85 -0
- data/sig/imagekitio/models/overlay_timing.rbs +66 -0
- data/sig/imagekitio/models/responsive_image_attributes.rbs +36 -0
- data/sig/imagekitio/models/solid_color_overlay.rbs +38 -0
- data/sig/imagekitio/models/solid_color_overlay_transformation.rbs +97 -0
- data/sig/imagekitio/models/src_options.rbs +64 -0
- data/sig/imagekitio/models/streaming_resolution.rbs +20 -0
- data/sig/imagekitio/models/subtitle_overlay.rbs +59 -0
- data/sig/imagekitio/models/subtitle_overlay_transformation.rbs +78 -0
- data/sig/imagekitio/models/text_overlay.rbs +59 -0
- data/sig/imagekitio/models/text_overlay_transformation.rbs +195 -0
- data/sig/imagekitio/models/transformation.rbs +763 -0
- data/sig/imagekitio/models/transformation_position.rbs +14 -0
- data/sig/imagekitio/models/unsafe_unwrap_webhook_event.rbs +18 -0
- data/sig/imagekitio/models/unwrap_webhook_event.rbs +18 -0
- data/sig/imagekitio/models/update_file_request.rbs +122 -0
- data/sig/imagekitio/models/upload_post_transform_error_event.rbs +192 -0
- data/sig/imagekitio/models/upload_post_transform_success_event.rbs +142 -0
- data/sig/imagekitio/models/upload_pre_transform_error_event.rbs +115 -0
- data/sig/imagekitio/models/upload_pre_transform_success_event.rbs +541 -0
- data/sig/imagekitio/models/video_overlay.rbs +59 -0
- data/sig/imagekitio/models/video_transformation_accepted_event.rbs +261 -0
- data/sig/imagekitio/models/video_transformation_error_event.rbs +300 -0
- data/sig/imagekitio/models/video_transformation_ready_event.rbs +359 -0
- data/sig/imagekitio/models/webhook_unsafe_unwrap_params.rbs +15 -0
- data/sig/imagekitio/models/webhook_unwrap_params.rbs +15 -0
- data/sig/imagekitio/models.rbs +119 -0
- data/sig/imagekitio/request_options.rbs +36 -0
- data/sig/imagekitio/resources/accounts/origins.rbs +34 -0
- data/sig/imagekitio/resources/accounts/url_endpoints.rbs +40 -0
- data/sig/imagekitio/resources/accounts/usage.rbs +15 -0
- data/sig/imagekitio/resources/accounts.rbs +13 -0
- data/sig/imagekitio/resources/assets.rbs +18 -0
- data/sig/imagekitio/resources/beta/v2/files.rbs +35 -0
- data/sig/imagekitio/resources/beta/v2.rbs +11 -0
- data/sig/imagekitio/resources/beta.rbs +9 -0
- data/sig/imagekitio/resources/cache/invalidation.rbs +19 -0
- data/sig/imagekitio/resources/cache.rbs +9 -0
- data/sig/imagekitio/resources/custom_metadata_fields.rbs +32 -0
- data/sig/imagekitio/resources/files/bulk.rbs +32 -0
- data/sig/imagekitio/resources/files/metadata.rbs +19 -0
- data/sig/imagekitio/resources/files/versions.rbs +32 -0
- data/sig/imagekitio/resources/files.rbs +76 -0
- data/sig/imagekitio/resources/folders/job.rbs +14 -0
- data/sig/imagekitio/resources/folders.rbs +40 -0
- data/sig/imagekitio/resources/webhooks.rbs +27 -0
- data/sig/imagekitio/version.rbs +3 -0
- metadata +470 -136
- data/Rakefile +0 -27
- data/lib/active_storage/active_storage.rb +0 -7
- data/lib/active_storage/service/ik_file.rb +0 -115
- data/lib/active_storage/service/image_kit_io_service.rb +0 -188
- data/lib/carrierwave/carrierwave.rb +0 -83
- data/lib/carrierwave/storage/ik_file.rb +0 -51
- data/lib/carrierwave/storage/imagekit_store.rb +0 -68
- data/lib/carrierwave/support/uri_filename.rb +0 -12
- data/lib/imagekitio/api_service/bulk.rb +0 -58
- data/lib/imagekitio/api_service/custom_metadata_field.rb +0 -52
- data/lib/imagekitio/api_service/file.rb +0 -221
- data/lib/imagekitio/api_service/folder.rb +0 -49
- data/lib/imagekitio/base.rb +0 -12
- data/lib/imagekitio/configurable.rb +0 -43
- data/lib/imagekitio/constant.rb +0 -36
- data/lib/imagekitio/constants/default.rb +0 -22
- data/lib/imagekitio/constants/error.rb +0 -69
- data/lib/imagekitio/constants/file.rb +0 -11
- data/lib/imagekitio/constants/supported_transformation.rb +0 -39
- data/lib/imagekitio/constants/url.rb +0 -14
- data/lib/imagekitio/railtie.rb +0 -4
- data/lib/imagekitio/request.rb +0 -98
- data/lib/imagekitio/sdk/version.rb +0 -5
- data/lib/imagekitio/url.rb +0 -216
- data/lib/imagekitio/utils/calculation.rb +0 -45
- data/lib/imagekitio/utils/formatter.rb +0 -48
- data/lib/imagekitio/utils/option_validator.rb +0 -36
- data/lib/tasks/imagekitio/imagekitio_tasks.rake +0 -4
data/README.md
CHANGED
|
@@ -1,885 +1,744 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
|
|
9
|
-
[
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
# ImageKit.io Ruby SDK
|
|
2
|
+
|
|
3
|
+
The ImageKit Ruby library provides convenient access to the ImageKit REST API from any Ruby 3.2.0+ application. The library supports building and transforming URLs, generating signed URLs for secure content delivery, and handling file uploads. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
The official [ImageKit Ruby documentation](https://imagekit.io/docs/integration/ruby) provides complete integration guides and examples.
|
|
8
|
+
|
|
9
|
+
If you're using Ruby on Rails, the [ImageKit Rails gem](https://github.com/imagekit-developer/imagekit-rails) builds on top of this SDK to provide [Rails-specific integrations](https://imagekit.io/docs/integration/ruby/ruby-on-rails) including Active Storage and view helpers.
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [File uploads](#file-uploads)
|
|
17
|
+
- [URL Generation](#url-generation)
|
|
18
|
+
- [Basic URL generation](#basic-url-generation)
|
|
19
|
+
- [URL generation with transformations](#url-generation-with-transformations)
|
|
20
|
+
- [URL generation with image overlay](#url-generation-with-image-overlay)
|
|
21
|
+
- [URL generation with text overlay](#url-generation-with-text-overlay)
|
|
22
|
+
- [Signed URLs for secure delivery](#signed-urls-for-secure-delivery)
|
|
23
|
+
- [Chained transformations](#chained-transformations)
|
|
24
|
+
- [Using raw parameter for custom transformations](#using-raw-parameter-for-custom-transformations)
|
|
25
|
+
- [Helper Methods](#helper-methods)
|
|
26
|
+
- [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads)
|
|
27
|
+
- [Responsive image attributes](#responsive-image-attributes)
|
|
28
|
+
- [Handling errors](#handling-errors)
|
|
29
|
+
- [Retries](#retries)
|
|
30
|
+
- [Timeouts](#timeouts)
|
|
31
|
+
- [Advanced concepts](#advanced-concepts)
|
|
32
|
+
- [BaseModel](#basemodel)
|
|
33
|
+
- [Making custom or undocumented requests](#making-custom-or-undocumented-requests)
|
|
34
|
+
- [Concurrency & connection pooling](#concurrency--connection-pooling)
|
|
35
|
+
- [Sorbet](#sorbet)
|
|
36
|
+
- [Enums](#enums)
|
|
37
|
+
- [Versioning](#versioning)
|
|
38
|
+
- [Requirements](#requirements)
|
|
39
|
+
- [Contributing](#contributing)
|
|
40
40
|
|
|
41
41
|
## Installation
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
gem 'imagekitio'
|
|
47
|
-
```
|
|
45
|
+
<!-- x-release-please-start-version -->
|
|
48
46
|
|
|
49
|
-
And then execute:
|
|
50
|
-
```
|
|
51
|
-
$ bundle install
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Or install it yourself:
|
|
55
|
-
```
|
|
56
|
-
$ gem install imagekitio
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Initialization
|
|
60
|
-
|
|
61
|
-
Create a new file `config/initializers/imagekitio.rb` then add the configuration.
|
|
62
47
|
```ruby
|
|
63
|
-
|
|
64
|
-
if Rails.env.development?
|
|
65
|
-
config.public_key = 'your_public_api_key'
|
|
66
|
-
config.private_key = 'your_private_api_key'
|
|
67
|
-
config.url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
|
|
68
|
-
end
|
|
69
|
-
config.service = :carrierwave
|
|
70
|
-
#config.service = :active_storage
|
|
71
|
-
#config.constants.MISSING_PRIVATE_KEY = 'custom error message'
|
|
72
|
-
end
|
|
48
|
+
gem "imagekitio", "~> 4.0.0"
|
|
73
49
|
```
|
|
74
|
-
#### CarrierWave
|
|
75
|
-
You can create a CarrierWave uploader to attach pictures to your database objects as their attributes. Skip to [this section](https://github.com/imagekit-developer/imagekit-ruby#file-upload) to upload images without designating them as database attributes. Make sure to add service `:carrierwave` as shown in [initialization section](#initialization).
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
rails g uploader <Uploading_attribute_name>
|
|
79
|
-
# For example, if you want to create an uploader for Avatar attribute, then use
|
|
80
|
-
rails g uploader Avatar
|
|
81
|
-
# Generated uploader's path will be app/uploaders/avatar_uploader.rb
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
After that, you need to edit your generated uploader and make the following changes:
|
|
85
|
-
```ruby
|
|
86
|
-
# include this module inside the top of the uploader class
|
|
87
|
-
include ImageKitIo::CarrierWave
|
|
88
50
|
|
|
89
|
-
|
|
51
|
+
<!-- x-release-please-end -->
|
|
90
52
|
|
|
91
|
-
|
|
92
|
-
options={
|
|
93
|
-
response_fields: 'isPrivateFile, tags',
|
|
94
|
-
tags: %w[abc def],
|
|
95
|
-
use_unique_file_name: false,
|
|
96
|
-
folder: "your_directory/"
|
|
97
|
-
}
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# If you want to set upload dir, then you can use the following method, or you can also use the options method.
|
|
101
|
-
# This method should return a string
|
|
102
|
-
def store_dir
|
|
103
|
-
"your_directory/"
|
|
104
|
-
end
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Then you need to modify your model. for example- if your model name is employee, then do these changes.
|
|
108
|
-
|
|
109
|
-
```ruby
|
|
110
|
-
class Employee < ApplicationRecord
|
|
111
|
-
attr_accessor :avatar
|
|
112
|
-
mount_uploader :avatar, AvatarUploader
|
|
113
|
-
end
|
|
114
|
-
```
|
|
53
|
+
## Usage
|
|
115
54
|
|
|
116
|
-
Get image url:
|
|
117
55
|
```ruby
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# To get the original image url, use
|
|
121
|
-
@employee.avatar.url
|
|
56
|
+
require "imagekitio"
|
|
122
57
|
|
|
123
|
-
|
|
124
|
-
|
|
58
|
+
image_kit = Imagekitio::Client.new(
|
|
59
|
+
private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted
|
|
60
|
+
)
|
|
125
61
|
|
|
62
|
+
response = image_kit.files.upload(
|
|
63
|
+
file: Pathname("/path/to/file"),
|
|
64
|
+
file_name: "file-name.jpg"
|
|
65
|
+
)
|
|
126
66
|
|
|
127
|
-
|
|
128
|
-
# options is a transformation options
|
|
129
|
-
@employee.avatar.url_with(options)
|
|
67
|
+
puts(response.file_id)
|
|
130
68
|
```
|
|
131
69
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Once you [install](https://guides.rubyonrails.org/active_storage_overview.html#setup) the active_storage gem, then any model can have the attachment using `has_one_attached` or `has_many_attached` like below:
|
|
70
|
+
### File uploads
|
|
135
71
|
|
|
136
|
-
|
|
137
|
-
class Employee < ApplicationRecord
|
|
138
|
-
has_one_attached :avatar
|
|
139
|
-
end
|
|
140
|
-
```
|
|
72
|
+
Request parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, or an `IO` stream.
|
|
141
73
|
|
|
142
|
-
Get image url:
|
|
143
74
|
```ruby
|
|
144
|
-
|
|
75
|
+
require "pathname"
|
|
145
76
|
|
|
146
|
-
#
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Now, let's configure active_storage as a service for the imagekitio.
|
|
151
|
-
|
|
152
|
-
First add `:active_storage` in initializer file.
|
|
77
|
+
# Use `Pathname` to stream from disk (memory efficient, supports retries):
|
|
78
|
+
response = image_kit.files.upload(file: Pathname("/path/to/file"))
|
|
153
79
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```
|
|
80
|
+
# Or pass file contents directly
|
|
81
|
+
response = image_kit.files.upload(file: File.read("/path/to/file"))
|
|
157
82
|
|
|
158
|
-
|
|
83
|
+
# Or, to control the filename and/or content type:
|
|
84
|
+
file = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")
|
|
85
|
+
response = image_kit.files.upload(file: file)
|
|
159
86
|
|
|
160
|
-
|
|
161
|
-
imagekitio:
|
|
162
|
-
service: ImageKitIo
|
|
87
|
+
puts(response.file_id)
|
|
163
88
|
```
|
|
164
89
|
|
|
90
|
+
Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound).
|
|
165
91
|
|
|
166
|
-
##
|
|
92
|
+
## URL Generation
|
|
167
93
|
|
|
168
|
-
|
|
94
|
+
The ImageKit SDK provides a powerful `helper.build_url()` method for generating optimized image and video URLs with transformations. Here are examples ranging from simple URLs to complex transformations with overlays and signed URLs.
|
|
169
95
|
|
|
170
|
-
|
|
171
|
-
* `File Upload`
|
|
172
|
-
* `File Management`
|
|
96
|
+
### Basic URL generation
|
|
173
97
|
|
|
174
|
-
|
|
98
|
+
Generate a simple URL without any transformations:
|
|
175
99
|
|
|
176
|
-
|
|
100
|
+
```ruby
|
|
101
|
+
require "imagekitio"
|
|
177
102
|
|
|
178
|
-
|
|
103
|
+
image_kit = Imagekitio::Client.new(
|
|
104
|
+
private_key: ENV["IMAGEKIT_PRIVATE_KEY"]
|
|
105
|
+
)
|
|
179
106
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
|
|
185
|
-
transformation: [{height: "300", width: "400", raw: "ar-4-3,q-40"}]
|
|
107
|
+
# Basic URL without transformations
|
|
108
|
+
url = image_kit.helper.build_url({
|
|
109
|
+
src: "/default-image.jpg",
|
|
110
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id"
|
|
186
111
|
})
|
|
187
|
-
```
|
|
188
112
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400,ar-4-3,q-40/default-image.jpg
|
|
113
|
+
puts url
|
|
114
|
+
# Output: https://ik.imagekit.io/your_imagekit_id/default-image.jpg
|
|
192
115
|
```
|
|
193
116
|
|
|
194
|
-
|
|
195
|
-
This method allows you to add transformation parameters to an absolute URL. For example, if you have configured a custom CNAME and have absolute asset URLs in your database or CMS, you will often need this.
|
|
196
|
-
|
|
117
|
+
You can also use absolute URLs:
|
|
197
118
|
|
|
198
119
|
```ruby
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
120
|
+
url = image_kit.helper.build_url({
|
|
121
|
+
src: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",
|
|
122
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id"
|
|
202
123
|
})
|
|
203
124
|
```
|
|
204
125
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-400
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
The `.url()` method accepts the following parameters
|
|
213
|
-
|
|
214
|
-
| Option | Description |
|
|
215
|
-
| :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
216
|
-
| url_endpoint | Optional. The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified at the time of SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/ |
|
|
217
|
-
| path | Conditional. This is the path at which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. |
|
|
218
|
-
| src | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. |
|
|
219
|
-
| transformation | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as different objects of the array. The complete list of supported transformations in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. |
|
|
220
|
-
| transformation_position | Optional. The default value is `path` that places the transformation string as a path parameter in the URL. It can also be specified as `query`, which adds the transformation string as the query parameter `tr` in the URL. If you use `src` parameter to create the URL, then the transformation string is always added as a query parameter. |
|
|
221
|
-
| query_parameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs. |
|
|
222
|
-
| signed | Optional. Boolean. Default is `false`. If set to `true`, the SDK generates a signed image URL adding the image signature to the image URL. This can only be used if you are creating the URL with the `url_endpoint` and `path` parameters and not with the `src` parameter. |
|
|
223
|
-
| expire_seconds | Optional. Integer. Meant to be used along with the `signed` parameter to specify the time in seconds from now when the URL should expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly. |
|
|
126
|
+
### URL generation with transformations
|
|
224
127
|
|
|
225
|
-
|
|
226
|
-
## Examples of generating URLs
|
|
227
|
-
**1. Chained Transformations as a query parameter**
|
|
128
|
+
Apply common transformations like resizing, cropping, and format conversion:
|
|
228
129
|
|
|
229
130
|
```ruby
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
131
|
+
# URL with basic transformations
|
|
132
|
+
url = image_kit.helper.build_url({
|
|
133
|
+
src: "/path/to/image.jpg",
|
|
134
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
135
|
+
transformation: [
|
|
136
|
+
{
|
|
137
|
+
width: 400,
|
|
138
|
+
height: 300,
|
|
139
|
+
crop: :maintain_ratio,
|
|
140
|
+
quality: 80,
|
|
141
|
+
format_: :webp
|
|
142
|
+
}
|
|
143
|
+
]
|
|
240
144
|
})
|
|
145
|
+
# Output: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp
|
|
241
146
|
```
|
|
242
|
-
Sample Result URL -
|
|
243
|
-
```
|
|
244
|
-
https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-400%3Art-90
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
**2. Sharpening and contrast transforms and a progressive JPG image**
|
|
248
|
-
|
|
249
|
-
There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation)
|
|
250
|
-
that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify
|
|
251
|
-
the value as "-" in the transformation object. Otherwise, specify the value that you want to be
|
|
252
|
-
added to this transformation.
|
|
253
147
|
|
|
148
|
+
More transformation examples:
|
|
254
149
|
|
|
255
150
|
```ruby
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
151
|
+
# Image resizing and cropping
|
|
152
|
+
url = image_kit.helper.build_url({
|
|
153
|
+
src: "/product.jpg",
|
|
154
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
155
|
+
transformation: [
|
|
156
|
+
{
|
|
157
|
+
width: 800,
|
|
158
|
+
height: 600,
|
|
159
|
+
crop: :at_max,
|
|
160
|
+
focus: "auto"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
264
163
|
})
|
|
265
|
-
```
|
|
266
164
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
165
|
+
# Image effects
|
|
166
|
+
url = image_kit.helper.build_url({
|
|
167
|
+
src: "/photo.jpg",
|
|
168
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
169
|
+
transformation: [
|
|
170
|
+
{
|
|
171
|
+
blur: 10,
|
|
172
|
+
grayscale: true,
|
|
173
|
+
radius: 20
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
})
|
|
271
177
|
|
|
272
|
-
|
|
178
|
+
# Format and quality optimization
|
|
179
|
+
url = image_kit.helper.build_url({
|
|
180
|
+
src: "/image.jpg",
|
|
181
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
182
|
+
transformation: [
|
|
183
|
+
{
|
|
184
|
+
format_: :auto,
|
|
185
|
+
quality: 85,
|
|
186
|
+
progressive: true
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
})
|
|
190
|
+
```
|
|
273
191
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
192
|
+
### URL generation with image overlay
|
|
193
|
+
|
|
194
|
+
Add image overlays to your base image:
|
|
195
|
+
|
|
196
|
+
```ruby
|
|
197
|
+
# URL with image overlay
|
|
198
|
+
url = image_kit.helper.build_url({
|
|
199
|
+
src: "/path/to/base-image.jpg",
|
|
200
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
201
|
+
transformation: [
|
|
202
|
+
{
|
|
203
|
+
width: 500,
|
|
204
|
+
height: 400,
|
|
205
|
+
overlay: {
|
|
206
|
+
type: :image,
|
|
207
|
+
input: "/path/to/overlay-logo.png",
|
|
208
|
+
position: {
|
|
209
|
+
x: 10,
|
|
210
|
+
y_: 10
|
|
211
|
+
},
|
|
212
|
+
transformation: [
|
|
213
|
+
{
|
|
214
|
+
width: 100,
|
|
215
|
+
height: 50
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
})
|
|
222
|
+
# Output: URL with image overlay positioned at x:10, y:10
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### URL generation with text overlay
|
|
226
|
+
|
|
227
|
+
Add customized text overlays:
|
|
228
|
+
|
|
229
|
+
```ruby
|
|
230
|
+
# URL with text overlay
|
|
231
|
+
url = image_kit.helper.build_url({
|
|
232
|
+
src: "/path/to/base-image.jpg",
|
|
233
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
234
|
+
transformation: [
|
|
235
|
+
{
|
|
236
|
+
width: 600,
|
|
237
|
+
height: 400,
|
|
238
|
+
overlay: {
|
|
239
|
+
type: :text,
|
|
240
|
+
text: "Sample Text Overlay",
|
|
241
|
+
position: {
|
|
242
|
+
x: 50,
|
|
243
|
+
y_: 50,
|
|
244
|
+
focus: :center
|
|
245
|
+
},
|
|
246
|
+
transformation: [
|
|
247
|
+
{
|
|
248
|
+
font_size: 40,
|
|
249
|
+
font_family: "Arial",
|
|
250
|
+
font_color: "FFFFFF",
|
|
251
|
+
typography: "b" # bold
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
})
|
|
258
|
+
# Output: URL with bold white Arial text overlay at center position
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
You can combine multiple overlays for complex compositions:
|
|
262
|
+
|
|
263
|
+
```ruby
|
|
264
|
+
# URL with multiple overlays (text + image)
|
|
265
|
+
url = image_kit.helper.build_url({
|
|
266
|
+
src: "/path/to/base-image.jpg",
|
|
267
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
268
|
+
transformation: [
|
|
269
|
+
{
|
|
270
|
+
width: 800,
|
|
271
|
+
height: 600,
|
|
272
|
+
overlay: {
|
|
273
|
+
type: :text,
|
|
274
|
+
text: "Header Text",
|
|
275
|
+
position: { x: 20, y_: 20 },
|
|
276
|
+
transformation: [{ font_size: 30, font_color: "000000" }]
|
|
277
|
+
}
|
|
279
278
|
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
279
|
+
{
|
|
280
|
+
overlay: {
|
|
281
|
+
type: :image,
|
|
282
|
+
input: "/watermark.png",
|
|
283
|
+
position: { focus: :bottom_right },
|
|
284
|
+
transformation: [{ width: 100, opacity: 70 }]
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
]
|
|
286
288
|
})
|
|
289
|
+
# Output: URL with text overlay at top-left and semi-transparent watermark at bottom-right
|
|
287
290
|
```
|
|
288
|
-
**Sample Result URL**
|
|
289
|
-
```
|
|
290
|
-
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&ik-t=1567358667&ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
**4. Adding overlays**
|
|
294
291
|
|
|
295
|
-
|
|
292
|
+
### Signed URLs for secure delivery
|
|
296
293
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
You can add any text string over a base video or image using a text layer (l-text).
|
|
300
|
-
|
|
301
|
-
For example:
|
|
294
|
+
Generate signed URLs that expire after a specified time for secure content delivery:
|
|
302
295
|
|
|
303
296
|
```ruby
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
297
|
+
# Generate a signed URL that expires in 1 hour (3600 seconds)
|
|
298
|
+
url = image_kit.helper.build_url({
|
|
299
|
+
src: "/private/secure-image.jpg",
|
|
300
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
301
|
+
transformation: [
|
|
302
|
+
{
|
|
303
|
+
width: 400,
|
|
304
|
+
height: 300,
|
|
305
|
+
quality: 90
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
signed: true,
|
|
309
|
+
expires_in: 3600 # URL expires in 1 hour
|
|
312
310
|
})
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
311
|
+
# Output: URL with signature parameters (?ik-t=timestamp&ik-s=signature)
|
|
312
|
+
|
|
313
|
+
# Generate a signed URL that doesn't expire
|
|
314
|
+
url = image_kit.helper.build_url({
|
|
315
|
+
src: "/private/secure-image.jpg",
|
|
316
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
317
|
+
signed: true
|
|
318
|
+
# No expires_in means the URL won't expire
|
|
319
|
+
})
|
|
320
|
+
# Output: URL with signature parameter (?ik-s=signature)
|
|
317
321
|
```
|
|
318
322
|
|
|
319
|
-
|
|
323
|
+
### Chained transformations
|
|
320
324
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
For example:
|
|
325
|
+
Apply multiple transformation steps by passing multiple transformation objects. Each transformation is applied sequentially:
|
|
324
326
|
|
|
325
327
|
```ruby
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
328
|
+
# First resize, then apply effects
|
|
329
|
+
url = image_kit.helper.build_url({
|
|
330
|
+
src: "/default-image.jpg",
|
|
331
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
332
|
+
transformation: [
|
|
333
|
+
{
|
|
334
|
+
width: 400,
|
|
335
|
+
height: 300
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
rotation: 90,
|
|
339
|
+
blur: 5
|
|
340
|
+
}
|
|
341
|
+
]
|
|
334
342
|
})
|
|
343
|
+
# Output: https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-400,h-300:rt-90,bl-5
|
|
335
344
|
```
|
|
336
|
-
**Sample Result URL**
|
|
337
|
-
```
|
|
338
|
-
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
**Solid color blocks as overlays**
|
|
342
345
|
|
|
343
|
-
|
|
346
|
+
### Using raw parameter for custom transformations
|
|
344
347
|
|
|
345
|
-
|
|
348
|
+
ImageKit frequently adds new transformation parameters that might not yet be documented in the SDK. You can use the `raw` parameter to access these features or create custom transformation strings:
|
|
346
349
|
|
|
347
350
|
```ruby
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
# Using raw parameter for custom transformations
|
|
352
|
+
url = image_kit.helper.build_url({
|
|
353
|
+
src: "/path/to/image.jpg",
|
|
354
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
355
|
+
transformation: [
|
|
356
|
+
{
|
|
357
|
+
width: 400,
|
|
358
|
+
height: 300,
|
|
359
|
+
raw: "something-new"
|
|
360
|
+
}
|
|
361
|
+
]
|
|
356
362
|
})
|
|
357
|
-
|
|
358
|
-
**Sample Result URL**
|
|
359
|
-
```
|
|
360
|
-
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4
|
|
363
|
+
# Output: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,something-new
|
|
361
364
|
```
|
|
362
365
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic.
|
|
366
|
-
|
|
367
|
-
For example:
|
|
366
|
+
You can control where transformations appear in the URL:
|
|
368
367
|
|
|
369
368
|
```ruby
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow
|
|
369
|
+
# Add transformations to the URL path instead of query parameters
|
|
370
|
+
url = image_kit.helper.build_url({
|
|
371
|
+
src: "/default-image.jpg",
|
|
372
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
373
|
+
transformation_position: :path,
|
|
374
|
+
transformation: [
|
|
375
|
+
{
|
|
376
|
+
width: 400,
|
|
377
|
+
height: 300
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
})
|
|
381
|
+
# Output: https://ik.imagekit.io/your_imagekit_id/tr:w-400,h-300/default-image.jpg
|
|
384
382
|
```
|
|
385
383
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations). The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable.
|
|
389
|
-
|
|
390
|
-
If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using the `url` function.
|
|
391
|
-
|
|
392
|
-
If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter.
|
|
393
|
-
|
|
394
|
-
| Supported Transformation Name | Translates to parameter |
|
|
395
|
-
|-------------------------------|-------------------------|
|
|
396
|
-
| height | h |
|
|
397
|
-
| width | w |
|
|
398
|
-
| aspect_ratio | ar |
|
|
399
|
-
| quality | q |
|
|
400
|
-
| crop | c |
|
|
401
|
-
| crop_mode | cm |
|
|
402
|
-
| x | x |
|
|
403
|
-
| y | y |
|
|
404
|
-
| focus | fo |
|
|
405
|
-
| format | f |
|
|
406
|
-
| radius | r |
|
|
407
|
-
| background | bg |
|
|
408
|
-
| border | b |
|
|
409
|
-
| rotation | rt |
|
|
410
|
-
| blur | bl |
|
|
411
|
-
| named | n |
|
|
412
|
-
| progressive | pr |
|
|
413
|
-
| lossless | lo |
|
|
414
|
-
| trim | t |
|
|
415
|
-
| metadata | md |
|
|
416
|
-
| color_profile | cp |
|
|
417
|
-
| default_image | di |
|
|
418
|
-
| dpr | dpr |
|
|
419
|
-
| effect_sharpen | e-sharpen |
|
|
420
|
-
| effect_usm | e-usm |
|
|
421
|
-
| effect_contrast | e-contrast |
|
|
422
|
-
| effect_gray | e-grayscale |
|
|
423
|
-
| effect_shadow | e-shadow |
|
|
424
|
-
| effect_gradient | e-gradient |
|
|
425
|
-
| original | orig |
|
|
426
|
-
| raw | `replaced by the parameter value` |
|
|
427
|
-
|
|
428
|
-
## File Upload
|
|
429
|
-
This method can be used to directly upload images to your ImageKit Media Library without giving it the designation of an attribute of any database object.
|
|
430
|
-
|
|
431
|
-
The SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media library. It
|
|
432
|
-
accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload).
|
|
433
|
-
|
|
434
|
-
The `upload()` method requires at least the `file` and the `file_name` parameter to upload a file and returns
|
|
435
|
-
a callback with the `error` and `result` as arguments. You can pass other parameters supported by the
|
|
436
|
-
ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload, use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload).
|
|
437
|
-
|
|
438
|
-
Simple usage
|
|
384
|
+
Add custom query parameters:
|
|
439
385
|
|
|
440
386
|
```ruby
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
387
|
+
url = image_kit.helper.build_url({
|
|
388
|
+
src: "/default-image.jpg",
|
|
389
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
390
|
+
query_parameters: {
|
|
391
|
+
version: "1",
|
|
392
|
+
cache: "max"
|
|
393
|
+
}
|
|
394
|
+
})
|
|
449
395
|
```
|
|
450
396
|
|
|
451
|
-
|
|
452
|
-
servers. If the upload fails, `error` will be the same as what is received from ImageKit's servers, and the result will
|
|
453
|
-
be `None`.
|
|
454
|
-
|
|
455
|
-
## File Management
|
|
456
|
-
|
|
457
|
-
The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api)
|
|
458
|
-
to manage your files. This also returns `error` and `result`. The `error` will be `None` if API succeeds.
|
|
397
|
+
## Helper Methods
|
|
459
398
|
|
|
460
|
-
|
|
399
|
+
The SDK provides several helper methods for common ImageKit operations.
|
|
461
400
|
|
|
462
|
-
|
|
463
|
-
in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#list-and-search-file-api) can be passed with the
|
|
464
|
-
correct values to get the results.
|
|
401
|
+
### Authentication parameters for client-side uploads
|
|
465
402
|
|
|
466
|
-
|
|
467
|
-
imagekitio.list_files(
|
|
468
|
-
skip: 0,
|
|
469
|
-
limit: 5
|
|
470
|
-
)
|
|
471
|
-
```
|
|
472
|
-
**Get File Details**
|
|
473
|
-
Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details)
|
|
403
|
+
Generate authentication parameters for secure client-side file uploads. These parameters allow you to securely upload files directly from the browser without exposing your private API key:
|
|
474
404
|
|
|
475
405
|
```ruby
|
|
476
|
-
imagekitio
|
|
477
|
-
file_id: '598821f949c0a938d57563bd'
|
|
478
|
-
)
|
|
479
|
-
```
|
|
406
|
+
require "imagekitio"
|
|
480
407
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
```ruby
|
|
484
|
-
imagekit.get_file_metadata(
|
|
485
|
-
file_id: '598821f949c0a938d57563bd'
|
|
408
|
+
image_kit = Imagekitio::Client.new(
|
|
409
|
+
private_key: ENV["IMAGEKIT_PRIVATE_KEY"]
|
|
486
410
|
)
|
|
487
|
-
```
|
|
488
411
|
|
|
489
|
-
|
|
490
|
-
|
|
412
|
+
# Generate authentication parameters with default expiry (30 minutes)
|
|
413
|
+
auth_params = image_kit.helper.get_authentication_parameters
|
|
491
414
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
remote_file_url: "https://ik.imagekit.io/demo/tr:w-100/default-image.jpg"
|
|
495
|
-
)
|
|
415
|
+
puts auth_params
|
|
416
|
+
# Output: { token: "unique-token", expire: 1234567890, signature: "signature-hash" }
|
|
496
417
|
```
|
|
497
418
|
|
|
498
|
-
|
|
499
|
-
Update parameters associated with the file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/update-file-details).
|
|
500
|
-
The first argument to the `update_field_details` method is the file ID, and a second argument is an object with the
|
|
501
|
-
parameters to be updated.
|
|
419
|
+
Customize the token and expiration:
|
|
502
420
|
|
|
503
421
|
```ruby
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
422
|
+
# Custom token and expiry (1 hour from now)
|
|
423
|
+
auth_params = image_kit.helper.get_authentication_parameters(
|
|
424
|
+
token: "my-custom-token",
|
|
425
|
+
expire: Time.now.to_i + 3600
|
|
508
426
|
)
|
|
427
|
+
# Output: { token: "my-custom-token", expire: 1234567890, signature: "generated-signature" }
|
|
509
428
|
```
|
|
510
429
|
|
|
511
|
-
|
|
430
|
+
These authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key.
|
|
512
431
|
|
|
513
|
-
|
|
432
|
+
### Responsive image attributes
|
|
514
433
|
|
|
515
|
-
|
|
516
|
-
imagekitio.copy_file(
|
|
517
|
-
source_file_path: '/path/to/file.jpg',
|
|
518
|
-
destination_path: '/folder/to/copy/into',
|
|
519
|
-
include_file_versions: true #default false
|
|
520
|
-
)
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
**Move File**
|
|
524
|
-
|
|
525
|
-
Move file from one folder to another folder using the source file path and destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-file)
|
|
434
|
+
Generate responsive image attributes for HTML `<img>` tags. This creates optimized `srcset` and `sizes` attributes for responsive images:
|
|
526
435
|
|
|
527
436
|
```ruby
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
437
|
+
# Width-based responsive images (generates w descriptors)
|
|
438
|
+
attrs = image_kit.helper.get_responsive_image_attributes({
|
|
439
|
+
src: "/default-image.jpg",
|
|
440
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
441
|
+
sizes: "(min-width: 768px) 50vw, 100vw",
|
|
442
|
+
transformation: [
|
|
443
|
+
{
|
|
444
|
+
quality: 80,
|
|
445
|
+
format_: :auto
|
|
446
|
+
}
|
|
447
|
+
]
|
|
448
|
+
})
|
|
533
449
|
|
|
534
|
-
|
|
450
|
+
puts attrs.src
|
|
451
|
+
# Largest candidate URL
|
|
535
452
|
|
|
536
|
-
|
|
453
|
+
puts attrs.src_set
|
|
454
|
+
# URL1 640w, URL2 750w, URL3 1080w, ...
|
|
537
455
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
file_path: '/path/to/old-file-name.jpg',
|
|
541
|
-
new_file_name: 'new-file-name.jpg',
|
|
542
|
-
purge_cache: true #optional
|
|
543
|
-
)
|
|
456
|
+
puts attrs.sizes
|
|
457
|
+
# (min-width: 768px) 50vw, 100vw
|
|
544
458
|
```
|
|
545
459
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file). The method accepts the file ID of the file that has to be deleted.
|
|
460
|
+
DPR-based responsive images (generates x descriptors):
|
|
549
461
|
|
|
550
462
|
```ruby
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
463
|
+
# When width is provided without sizes, generates 1x and 2x variants
|
|
464
|
+
attrs = image_kit.helper.get_responsive_image_attributes({
|
|
465
|
+
src: "/profile.jpg",
|
|
466
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
467
|
+
width: 400,
|
|
468
|
+
transformation: [
|
|
469
|
+
{
|
|
470
|
+
quality: 85
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
})
|
|
556
474
|
|
|
557
|
-
|
|
475
|
+
puts attrs.src_set
|
|
476
|
+
# URL1 1x, URL2 2x
|
|
558
477
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
file_id: '598821f949c0a938d57563bd'
|
|
562
|
-
)
|
|
478
|
+
puts attrs.width
|
|
479
|
+
# 400
|
|
563
480
|
```
|
|
564
|
-
**File version details**
|
|
565
481
|
|
|
566
|
-
|
|
482
|
+
Custom breakpoints for device widths:
|
|
567
483
|
|
|
568
484
|
```ruby
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
485
|
+
attrs = image_kit.helper.get_responsive_image_attributes({
|
|
486
|
+
src: "/default-image.jpg",
|
|
487
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
488
|
+
sizes: "100vw",
|
|
489
|
+
device_breakpoints: [320, 640, 1024, 1920],
|
|
490
|
+
image_breakpoints: [16, 32, 64],
|
|
491
|
+
transformation: [
|
|
492
|
+
{
|
|
493
|
+
crop: :at_max
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
})
|
|
573
497
|
```
|
|
574
498
|
|
|
575
|
-
|
|
499
|
+
The returned attributes can be directly used in your HTML:
|
|
576
500
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
501
|
+
```erb
|
|
502
|
+
<img
|
|
503
|
+
src="<%= attrs.src %>"
|
|
504
|
+
srcset="<%= attrs.src_set %>"
|
|
505
|
+
sizes="<%= attrs.sizes %>"
|
|
506
|
+
alt="Responsive image"
|
|
507
|
+
/>
|
|
584
508
|
```
|
|
585
509
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
Restore deleted file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/restore-file-version). The method accepts the file ID and version ID of the file.
|
|
510
|
+
Generate signed responsive image URLs:
|
|
589
511
|
|
|
590
512
|
```ruby
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
513
|
+
# Generate signed responsive image URLs
|
|
514
|
+
attrs = image_kit.helper.get_responsive_image_attributes({
|
|
515
|
+
src: "/default-image.jpg",
|
|
516
|
+
url_endpoint: "https://ik.imagekit.io/your_imagekit_id",
|
|
517
|
+
sizes: "100vw",
|
|
518
|
+
signed: true,
|
|
519
|
+
expires_in: 3600,
|
|
520
|
+
transformation: [
|
|
521
|
+
{
|
|
522
|
+
quality: 80
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
})
|
|
595
526
|
```
|
|
596
527
|
|
|
597
|
-
|
|
528
|
+
### Handling errors
|
|
598
529
|
|
|
599
|
-
|
|
600
|
-
deleted.
|
|
530
|
+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:
|
|
601
531
|
|
|
602
532
|
```ruby
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
)
|
|
533
|
+
begin
|
|
534
|
+
file = image_kit.files.upload(
|
|
535
|
+
file: File.read("/path/to/file.jpg"),
|
|
536
|
+
file_name: "file-name.jpg"
|
|
537
|
+
)
|
|
538
|
+
rescue Imagekitio::Errors::APIConnectionError => e
|
|
539
|
+
puts("The server could not be reached")
|
|
540
|
+
puts(e.cause) # an underlying Exception, likely raised within `net/http`
|
|
541
|
+
rescue Imagekitio::Errors::RateLimitError => e
|
|
542
|
+
puts("A 429 status code was received; we should back off a bit.")
|
|
543
|
+
rescue Imagekitio::Errors::APIStatusError => e
|
|
544
|
+
puts("Another non-200-range status code was received")
|
|
545
|
+
puts(e.status)
|
|
546
|
+
end
|
|
606
547
|
```
|
|
607
548
|
|
|
608
|
-
|
|
609
|
-
Programmatically issue a clear cache request as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache).
|
|
610
|
-
Accepts the full URL of the file for which the cache has to be cleared.
|
|
549
|
+
Error codes are as follows:
|
|
611
550
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
551
|
+
| Cause | Error Type |
|
|
552
|
+
| ---------------- | -------------------------- |
|
|
553
|
+
| HTTP 400 | `BadRequestError` |
|
|
554
|
+
| HTTP 401 | `AuthenticationError` |
|
|
555
|
+
| HTTP 403 | `PermissionDeniedError` |
|
|
556
|
+
| HTTP 404 | `NotFoundError` |
|
|
557
|
+
| HTTP 409 | `ConflictError` |
|
|
558
|
+
| HTTP 422 | `UnprocessableEntityError` |
|
|
559
|
+
| HTTP 429 | `RateLimitError` |
|
|
560
|
+
| HTTP >= 500 | `InternalServerError` |
|
|
561
|
+
| Other HTTP error | `APIStatusError` |
|
|
562
|
+
| Timeout | `APITimeoutError` |
|
|
563
|
+
| Network error | `APIConnectionError` |
|
|
618
564
|
|
|
619
|
-
|
|
620
|
-
[API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status)
|
|
565
|
+
### Retries
|
|
621
566
|
|
|
622
|
-
|
|
623
|
-
imagekitio.purge_file_cache_status(
|
|
624
|
-
request_id: '598821f949c0a938d57543bd'
|
|
625
|
-
)
|
|
626
|
-
```
|
|
567
|
+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
|
|
627
568
|
|
|
628
|
-
|
|
569
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
|
|
629
570
|
|
|
630
|
-
|
|
571
|
+
You can use the `max_retries` option to configure or disable this:
|
|
631
572
|
|
|
632
573
|
```ruby
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
574
|
+
# Configure the default for all requests:
|
|
575
|
+
image_kit = Imagekitio::Client.new(
|
|
576
|
+
max_retries: 0 # default is 2
|
|
636
577
|
)
|
|
637
|
-
```
|
|
638
578
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
imagekitio.delete_bulk_tags(
|
|
645
|
-
file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'],
|
|
646
|
-
tags: ['custom_tags', 'image']
|
|
579
|
+
# Or, configure per-request:
|
|
580
|
+
image_kit.files.upload(
|
|
581
|
+
file: File.read("/path/to/file.jpg"),
|
|
582
|
+
file_name: "file-name.jpg",
|
|
583
|
+
request_options: {max_retries: 5}
|
|
647
584
|
)
|
|
648
585
|
```
|
|
649
586
|
|
|
650
|
-
|
|
587
|
+
### Timeouts
|
|
651
588
|
|
|
652
|
-
|
|
589
|
+
By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:
|
|
653
590
|
|
|
654
591
|
```ruby
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
592
|
+
# Configure the default for all requests:
|
|
593
|
+
image_kit = Imagekitio::Client.new(
|
|
594
|
+
timeout: nil # default is 60
|
|
658
595
|
)
|
|
659
|
-
```
|
|
660
|
-
|
|
661
|
-
**Create Folder**
|
|
662
|
-
|
|
663
|
-
Create folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/create-folder)
|
|
664
596
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
597
|
+
# Or, configure per-request:
|
|
598
|
+
image_kit.files.upload(
|
|
599
|
+
file: File.read("/path/to/file.jpg"),
|
|
600
|
+
file_name: "file-name.jpg",
|
|
601
|
+
request_options: {timeout: 5}
|
|
669
602
|
)
|
|
670
603
|
```
|
|
671
604
|
|
|
605
|
+
On timeout, `Imagekitio::Errors::APITimeoutError` is raised.
|
|
672
606
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
Copy folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-folder)
|
|
676
|
-
|
|
677
|
-
```ruby
|
|
678
|
-
imagekitio.copy_folder(
|
|
679
|
-
source_folder_path: '/folder/to/copy',
|
|
680
|
-
destination_path: '/folder/to/copy/into',
|
|
681
|
-
include_file_versions: true #default false
|
|
682
|
-
)
|
|
683
|
-
```
|
|
607
|
+
Note that requests that time out are retried by default.
|
|
684
608
|
|
|
685
|
-
|
|
609
|
+
## Advanced concepts
|
|
686
610
|
|
|
687
|
-
|
|
611
|
+
### BaseModel
|
|
688
612
|
|
|
689
|
-
|
|
690
|
-
imagekitio.move_folder(
|
|
691
|
-
source_folder_path: '/folder/to/move',
|
|
692
|
-
destination_path: '/folder/to/move/into/'
|
|
693
|
-
)
|
|
694
|
-
```
|
|
613
|
+
All parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:
|
|
695
614
|
|
|
696
|
-
|
|
615
|
+
1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
|
|
697
616
|
|
|
698
|
-
|
|
617
|
+
2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
|
|
699
618
|
|
|
700
|
-
|
|
701
|
-
imagekitio.delete_folder(
|
|
702
|
-
folder_path: 'folder/to/delete'
|
|
703
|
-
)
|
|
704
|
-
```
|
|
619
|
+
3. Both instances and the classes themselves can be pretty-printed.
|
|
705
620
|
|
|
706
|
-
|
|
621
|
+
4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
|
|
707
622
|
|
|
708
|
-
|
|
623
|
+
### Making custom or undocumented requests
|
|
709
624
|
|
|
710
|
-
|
|
711
|
-
imagekitio.bulk_job_status(
|
|
712
|
-
job_id: '5e21880d5efe355febd4cccd'
|
|
713
|
-
)
|
|
714
|
-
```
|
|
625
|
+
#### Undocumented properties
|
|
715
626
|
|
|
716
|
-
|
|
627
|
+
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
|
|
717
628
|
|
|
718
|
-
|
|
629
|
+
Note: the `extra_` parameters of the same name overrides the documented parameters.
|
|
719
630
|
|
|
720
631
|
```ruby
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
632
|
+
response =
|
|
633
|
+
image_kit.files.upload(
|
|
634
|
+
file: File.read("/path/to/file.jpg"),
|
|
635
|
+
file_name: "file-name.jpg",
|
|
636
|
+
request_options: {
|
|
637
|
+
extra_query: {my_query_parameter: value},
|
|
638
|
+
extra_body: {my_body_parameter: value},
|
|
639
|
+
extra_headers: {"my-header": value}
|
|
729
640
|
}
|
|
730
|
-
)
|
|
731
|
-
```
|
|
641
|
+
)
|
|
732
642
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
Get the custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field)
|
|
736
|
-
|
|
737
|
-
```ruby
|
|
738
|
-
imagekitio.get_custom_metadata_fields(
|
|
739
|
-
include_deleted: true #optional
|
|
740
|
-
)
|
|
643
|
+
puts(response[:my_undocumented_property])
|
|
741
644
|
```
|
|
742
645
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
Update custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field)
|
|
646
|
+
#### Undocumented request params
|
|
746
647
|
|
|
747
|
-
|
|
748
|
-
imagekitio.update_custom_metadata_field(
|
|
749
|
-
id: '5e21880d5efe355febd4bccd', #field_id
|
|
750
|
-
label: 'custom-price', #Either label or schema or both should be given
|
|
751
|
-
schema: nil
|
|
752
|
-
)
|
|
753
|
-
```
|
|
648
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.
|
|
754
649
|
|
|
755
|
-
|
|
650
|
+
#### Undocumented endpoints
|
|
756
651
|
|
|
757
|
-
|
|
652
|
+
To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:
|
|
758
653
|
|
|
759
654
|
```ruby
|
|
760
|
-
|
|
761
|
-
|
|
655
|
+
response = client.request(
|
|
656
|
+
method: :post,
|
|
657
|
+
path: '/undocumented/endpoint',
|
|
658
|
+
query: {"dog": "woof"},
|
|
659
|
+
headers: {"useful-header": "interesting-value"},
|
|
660
|
+
body: {"hello": "world"}
|
|
762
661
|
)
|
|
763
662
|
```
|
|
764
663
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
Each media management function returns a hash with `response`, `error`, `status_code`, `headers`, `raw_body` keys with respective values.
|
|
768
|
-
|
|
769
|
-
```ruby
|
|
770
|
-
upload = imagekitio.upload_file(
|
|
771
|
-
file: file,
|
|
772
|
-
file_name: "default.jpg",
|
|
773
|
-
folder: '/test',
|
|
774
|
-
response_fields: 'tags,customCoordinates,isPrivateFile,metadata',
|
|
775
|
-
tags: %w[abc def],
|
|
776
|
-
use_unique_file_name: false,
|
|
777
|
-
is_private_file: true
|
|
778
|
-
)
|
|
779
|
-
puts upload[:status_code] # 200
|
|
780
|
-
puts upload[:headers]
|
|
781
|
-
|
|
782
|
-
# {
|
|
783
|
-
# "access-control-allow-origin"=>["*"],
|
|
784
|
-
# "x-ik-requestid"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"],
|
|
785
|
-
# "content-type"=>["application/json; charset=utf-8"],
|
|
786
|
-
# "content-length"=>["611"],
|
|
787
|
-
# "etag"=>["W/\"859-GOeZiRFGOZERjHBgRUhG0EGcODs\""],
|
|
788
|
-
# "date"=>["Wed, 29 Jun 2022 07:04:33 GMT"],
|
|
789
|
-
# "x-request-id"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"],
|
|
790
|
-
# "connection"=>["close"]
|
|
791
|
-
# }
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
puts upload[:raw_body]
|
|
795
|
-
# "{\"fileId\":\"62bjf980rb886bd691b86760\",\"name\":\"default.jpg\",\"size\":102117,\"versionInfo\":{\"id\":\"62bjf980rb886bd691b86760\",\"name\":\"Version 1\"},\"filePath\":\"/test/default.jpg\",\"url\":\"https://ik.imagekit.io/46865sdf6sdf/test/default.jpg\",\"fileType\":\"image\",\"height\":700,\"width\":1050,\"thumbnailUrl\":\"https://ik.imagekit.io/46865sdf6sdf/tr:n-ik_ml_thumbnail/test/default.jpg\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"isPrivateFile\":true,\"customCoordinates\":null,\"metadata\":{\"height\":700,\"width\":1050,\"size\":102117,\"format\":\"jpg\",\"hasColorProfile\":true,\"quality\":0,\"density\":72,\"hasTransparency\":false,\"exif\":{},\"pHash\":\"90249d9b1fc74367\"}}"
|
|
796
|
-
```
|
|
664
|
+
### Concurrency & connection pooling
|
|
797
665
|
|
|
798
|
-
|
|
666
|
+
The `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
|
|
799
667
|
|
|
800
|
-
|
|
668
|
+
Each instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
|
|
801
669
|
|
|
802
|
-
|
|
670
|
+
When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
|
|
803
671
|
|
|
804
|
-
|
|
672
|
+
Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
|
|
805
673
|
|
|
806
|
-
|
|
674
|
+
## Sorbet
|
|
807
675
|
|
|
808
|
-
|
|
676
|
+
This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
|
|
809
677
|
|
|
810
|
-
|
|
678
|
+
You can provide typesafe request parameters like so:
|
|
811
679
|
|
|
812
680
|
```ruby
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
681
|
+
image_kit.files.upload(
|
|
682
|
+
file: File.read("/path/to/file.jpg"),
|
|
683
|
+
file_name: "file-name.jpg"
|
|
684
|
+
)
|
|
818
685
|
```
|
|
819
686
|
|
|
820
|
-
|
|
687
|
+
Or, equivalently:
|
|
821
688
|
|
|
822
|
-
|
|
689
|
+
```ruby
|
|
690
|
+
# Hashes work, but are not typesafe:
|
|
691
|
+
image_kit.files.upload(
|
|
692
|
+
file: File.read("/path/to/file.jpg"),
|
|
693
|
+
file_name: "file-name.jpg"
|
|
694
|
+
)
|
|
823
695
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
696
|
+
# You can also splat a full Params class:
|
|
697
|
+
params = Imagekitio::FileUploadParams.new(
|
|
698
|
+
file: File.read("/path/to/file.jpg"),
|
|
699
|
+
file_name: "file-name.jpg"
|
|
700
|
+
)
|
|
701
|
+
image_kit.files.upload(**params)
|
|
702
|
+
```
|
|
828
703
|
|
|
704
|
+
### Enums
|
|
829
705
|
|
|
830
|
-
|
|
831
|
-
strings and returns a numeric value indicative of the level of difference between the two images.
|
|
706
|
+
Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
|
|
832
707
|
|
|
833
708
|
```ruby
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
# calculate the distance between them:
|
|
840
|
-
|
|
841
|
-
distance = imagekitio.phash_distance(first_hash, second_hash)
|
|
842
|
-
return distance
|
|
709
|
+
# :all
|
|
710
|
+
puts(Imagekitio::AssetListParams::FileType::ALL)
|
|
711
|
+
|
|
712
|
+
# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`
|
|
713
|
+
T.reveal_type(Imagekitio::AssetListParams::FileType::ALL)
|
|
843
714
|
```
|
|
844
715
|
|
|
845
|
-
|
|
716
|
+
Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
|
|
846
717
|
|
|
847
718
|
```ruby
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
719
|
+
# Using the enum constants preserves the tagged type information:
|
|
720
|
+
image_kit.assets.list(
|
|
721
|
+
file_type: Imagekitio::AssetListParams::FileType::ALL,
|
|
722
|
+
# …
|
|
723
|
+
)
|
|
853
724
|
|
|
854
|
-
|
|
855
|
-
|
|
725
|
+
# Literal values are also permissible:
|
|
726
|
+
image_kit.assets.list(
|
|
727
|
+
file_type: :all,
|
|
728
|
+
# …
|
|
729
|
+
)
|
|
856
730
|
```
|
|
857
731
|
|
|
858
|
-
##
|
|
859
|
-
There are three sample apps:
|
|
860
|
-
|
|
861
|
-
* Rails application using Carrierwave
|
|
862
|
-
* Rails application using ActiveStorage
|
|
863
|
-
* Plain ruby application
|
|
864
|
-
|
|
865
|
-
Please see the sample applications in [here](https://github.com/imagekit-samples/quickstart).
|
|
732
|
+
## Versioning
|
|
866
733
|
|
|
867
|
-
|
|
734
|
+
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
|
|
868
735
|
|
|
869
|
-
|
|
736
|
+
This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
|
|
870
737
|
|
|
871
|
-
|
|
872
|
-
- Include `ImageKitIo::CarrierWave` in uploader class(for Carrierwave).
|
|
873
|
-
- Remove `storage :imagekit_store` config from uploader.
|
|
874
|
-
- Rename class `ImageKit::ImageKitClient` to `ImageKitIo::Client`
|
|
875
|
-
- Rename class `ImageKitIo::ImageKitRequest` to `ImageKitIo::Request`
|
|
738
|
+
## Requirements
|
|
876
739
|
|
|
877
|
-
|
|
878
|
-
For any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io](mailto:support@imagekit.io)
|
|
740
|
+
Ruby 3.2.0 or higher.
|
|
879
741
|
|
|
880
|
-
##
|
|
881
|
-
- [Documentation](https://docs.imagekit.io)
|
|
882
|
-
- [Main website](https://imagekit.io)
|
|
742
|
+
## Contributing
|
|
883
743
|
|
|
884
|
-
|
|
885
|
-
Released under the MIT license.
|
|
744
|
+
See [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).
|