{"id":47669309,"url":"https://github.com/imagekit-developer/imagekit-java","last_synced_at":"2026-04-02T12:24:58.255Z","repository":{"id":38275698,"uuid":"247482558","full_name":"imagekit-developer/imagekit-java","owner":"imagekit-developer","description":"Java SDK for ImageKit.io API.","archived":false,"fork":false,"pushed_at":"2025-09-19T03:08:14.000Z","size":3043,"stargazers_count":17,"open_issues_count":7,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-19T05:30:34.231Z","etag":null,"topics":["image-manipulation","image-optimization"],"latest_commit_sha":null,"homepage":"https://imagekit.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imagekit-developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-03-15T14:28:50.000Z","updated_at":"2025-02-11T17:07:12.000Z","dependencies_parsed_at":"2023-12-21T05:03:55.370Z","dependency_job_id":"aa59abb1-3815-41fc-a021-06b311bc48d8","html_url":"https://github.com/imagekit-developer/imagekit-java","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/imagekit-developer/imagekit-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imagekit-developer","download_url":"https://codeload.github.com/imagekit-developer/imagekit-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31306024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T09:48:21.550Z","status":"ssl_error","status_checked_at":"2026-04-02T09:48:19.196Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-manipulation","image-optimization"],"created_at":"2026-04-02T12:24:57.530Z","updated_at":"2026-04-02T12:24:58.240Z","avatar_url":"https://github.com/imagekit-developer.png","language":"Java","readme":"# ImageKit Java SDK\n\n[![Java CI](https://github.com/imagekit-developer/imagekit-java/workflows/Java%20CI/badge.svg)](https://github.com/imagekit-developer/imagekit-java)\n[![Release](https://jitpack.io/v/com.github.imagekit-developer/imagekit-java.svg)](https://jitpack.io/#com.github.imagekit-developer/imagekit-java)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow\u0026style=social)](https://twitter.com/ImagekitIo)\n \nJava SDK for [ImageKit.io](https://imagekit.io/) that implements the new APIs and interface for performing different file operations.\n\nImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.\n\nTable of contents -\n * [Installation](#installation)\n * [Initialization](#initialization)\n * [Usage](#usage)\n * [Versioning](#versioning)\n * [URL generation](#url-generation)\n * [File upload](#file-upload)\n * [File management](#file-management)\n * [Utility functions](#utility-functions)\n * [Handling errors](#handling-errors)\n * [Support](#support)\n * [Links](#links)\n \n## Installation\n\n### Requirements\n\n- Java 1.8 or later\n\n### Gradle users\nStep 1. Add the JitPack repository to your build file\n```\nallprojects {\n  repositories {\n    ...\n    maven { url 'https://jitpack.io' }\n  }\n}\n```\nStep 2. Add the dependency on the project's `build.gradle`:\n```\ndependencies {\n        implementation 'com.github.imagekit-developer:imagekit-java:2.0.0'\n}\n```\n### Maven users\nStep 1. Add the JitPack repository to your build file\n```\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\nStep 2. Add the dependency in the POM file:\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.imagekit-developer\u003c/groupId\u003e\n    \u003cartifactId\u003eimagekit-java\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Initialization\n\n**Step 1**. Create a `config.properties` file inside `src/main/resources` of your project. And put essential values of keys [UrlEndpoint, PrivateKey, PublicKey], no need to use quote(`'` or `\"`) in values. \n\n You can get the value of [URL-endpoint](https://imagekit.io/dashboard#url-endpoints) from your ImageKit dashboard. API keys can be obtained from the [developer](https://imagekit.io/dashboard/developer/api-keys) section in your ImageKit dashboard.\n\n```editorconfig\n# Put essential values of keys [UrlEndpoint, PrivateKey, PublicKey]\nUrlEndpoint=your_public_api_key\nPrivateKey=your_private_api_key\nPublicKey=https://ik.imagekit.io/imagekit_id/\n```\n\n**Step 2**. Then you need to initialize ImageKit with that configuration. \n\n ```java\nimport io.imagekit.sdk.ImageKit;\nimport io.imagekit.sdk.config.Configuration;\nimport io.imagekit.sdk.utils.Utils;\nclass App {\n    public static void main(String[] args){\n        ImageKit imageKit=ImageKit.getInstance();\n        Configuration config=Utils.getSystemConfig(App.class);\n        imageKit.setConfig(config);\n    }\n}\n```\n\nor\n\n ```java\nimport io.imagekit.sdk.ImageKit;\nimport io.imagekit.sdk.config.Configuration;\nimport io.imagekit.sdk.utils.Utils;\nclass App {\n    public static void main(String[] args) {\n        ImageKit imageKit = ImageKit.getInstance();\n        Configuration config = new Configuration(\"your_public_key\", \"your_private_key\", \"your_url_endpoint\");\n        imageKit.setConfig(config);\n    }\n}\n```\n\n## Usage\nYou can use this Java SDK for 3 different kinds of methods:\n\n* URL generation\n* file upload\n* file management\n\nThe usage of the SDK has been explained below.\n\n## Change log\nThis document presents a list of changes that break the existing functionality of previous versions. We try our best to minimize these disruptions, but sometimes they are unavoidable and will be in major versions.\n\n### Breaking History:\n\nChanges from 1.0.3 -\u003e 2.0.0 are listed below\n\n1. Result `raw` object and `getMap()` properties:\n\n**What changed**\n- `raw` and `getMap()` has been deprecated.\n\n**Who is affected?**\n- This affects any development that uses the `raw` or `getMap()` from the response object of APIs and Result object.\n\n**How should I update my code?**\n- If you still need to use `raw` and `getMap()`, do this `result.getResponseMetaData().getRaw()`.\n \n2. Result object `message` and `isSuccessful` boolean properties:\n\n**What changed**\n- `message` and `isSuccessful` have been replaced with custom exceptions according to response code.\n\n**Who is affected?**\n- This affects any development that uses the `message` or `isSuccessful` from response object of APIs that is Result object.\n\n**How should I update my code?**\n- If you still need to use `message` it will be there in the custom exceptions that could be raised when calling the various API methods. `isSuccessful` can be understood to be `true` if the API method doesn't throw any exception.\n\n\n## URL generation\n\n**1. Using image path and URL-endpoint**\n\nThis method allows you to create an URL to access a file using the relative file path and the ImageKit URL endpoint (`urlEndpoint`). The file can be an image, video, or any other static file supported by ImageKit.\n\n```java\nMap\u003cString, String\u003e queryParam=new HashMap\u003c\u003e();\nqueryParam.put(\"v\",\"123\");\n\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"600\");\nscale.put(\"width\",\"400\");\nscale.put(\"raw\", \"ar-4-3,q-40\");\ntransformation.add(scale);\n    \nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"urlEndpoint\",\"https://ik.imagekit.io/your_imagekit_id/\");\noptions.put(\"path\",\"/default-image.jpg\");\noptions.put(\"transformation\", transformation);\n\nString url = ImageKit.getInstance().getUrl(options);\n```\nThe result in a URL like\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:w-400,h-600/default-image.jpg?v=123\n```\n\n**2. Using full image URL**\nThis 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.\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"600\");\nscale.put(\"width\",\"400\");\nscale.put(\"raw\", \"ar-4-3,q-40\");\ntransformation.add(scale);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"src\",\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\");\noptions.put(\"transformation\", transformation);\n\nString url = ImageKit.getInstance().getUrl(options);\n```\n\nThe results in a URL like\n\n```\nhttps://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-400,h-600\n```\n\nThe ```.getUrl()``` method accepts the following parameters\n\n| Option                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| :---------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| urlEndpoint            | Optional. `(Type: String)` The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified during SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/                                                                                                                                                                                                                                                                                                                                             |\n| path                    | Conditional. `(Type: String)` 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.                                                                                                                                                                                                                                                                                                                                                                                                |\n| src                     | Conditional. `(Type: String)` 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.                                                                                                                                                                                                                                                                                                                           |\n| transformation          | Optional. `(Type: List\u003cMap\u003cString,String\u003e\u003e)` 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. |\n| transformationPosition | Optional. `(Type: String)` 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 the `src` parameter to create the URL, then the transformation string is always added as a query parameter.                                                                                                                                                                                                                                 |\n| queryParameters        | Optional. `(Type: Map\u003cString, String\u003e)` 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.                                                                                                                                                                                                                                                                                                                           |\n| signed                  | Optional. `(Type: 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 create the URL with the `url_endpoint` and `path` parameters and not with the `src` parameter.                                                                                                                                                                                                                                                                                            |\n| expireSeconds          | Optional. `(Type: 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.                                                                                                                                                                                                                                                                                                                |\n\n\n## Examples of generating URLs\n**1. Chained Transformations as a query parameter**\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"300\");\nscale.put(\"width\",\"400\");\ntransformation.add(scale);\nMap\u003cString, String\u003e rotate=new HashMap\u003c\u003e();\nrotate.put(\"rotation\",\"90\");\ntransformation.add(rotate);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"path\",\"/default-image.jpg\");\noptions.put(\"transformationPosition\",\"query\");\noptions.put(\"transformation\", transformation);\n\nString url = ImageKit.getInstance().getUrl(options);\n```\n\nSample Result URL -\n```\nhttps://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300\u0026w-400:rt-90\n```\n\n**2. Sharpening and contrast transform and a progressive JPG image**\n\nThere are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation)\nthat can be added to the URL with or without any other value. To use such transforms without specifying a value, specify\nthe value as \"-\" in the transformation object. Otherwise, specify the value that you want to be\nadded to this transformation.\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"format\",\"jpg\");\nscale.put(\"progressive\",\"true\");\nscale.put(\"effect_sharpen\",\"-\");\nscale.put(\"effect_contrast\",\"1\");\ntransformation.add(scale);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"path\",\"/default-image.jpg\");\noptions.put(\"transformation\", transformation);\nString url = ImageKit.getInstance().getUrl(options);\n```\n\nNote that because the `src` parameter was used, the transformation string gets added as a query parameter.\n\n```\nhttps://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=f-jpg\u0026pr-true\u0026e-sharpen\u0026e-contrast-1\n```\n\n**3. Signed URL that expires in 300 seconds with the default URL endpoint and other query parameters**\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"600\");\nscale.put(\"width\",\"400\");\n\ntransformation.add(format);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"path\",\"/default-image.jpg\");\noptions.put(\"signed\",true);\noptions.put(\"expireSeconds\",300);\nString url = ImageKit.getInstance().getUrl(options);\n```\n**Sample Result URL**\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:h-600,w-400/default-image.jpg?ik-t=1567358667\u0026ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054\n```\n\n**4. Adding overlays**\n\nImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations.\n\n**Text as overlays**\n\nYou can add any text string over a base video or image using a text layer (l-text).\n\nFor example:\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"300\");\nscale.put(\"width\",\"400\");\nscale.put(\"raw\", \"l-text,i-Imagekit,fs-50,l-end\");\ntransformation.add(scale);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"src\",\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\");\noptions.put(\"transformation\", transformation);\n\nString url = ImageKit.getInstance().getUrl(options);\n```\n**Sample Result URL**\n```\nhttps://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300,w-400,l-text,i-Imagekit,fs-50,l-end\n```\n\n**Image as overlays**\n\nYou can add an image over a base video or image using an image layer (l-image).\n\nFor example:\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"300\");\nscale.put(\"width\",\"400\");\nscale.put(\"raw\", \"l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end\");\ntransformation.add(scale);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"src\",\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\");\noptions.put(\"transformation\", transformation);\n\nString url = ImageKit.getInstance().getUrl(options);\n```\n**Sample Result URL**\n```\nhttps://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end\n```\n\n**Solid color blocks as overlays**\n\nYou can add solid color blocks over a base video or image using an image layer (l-image).\n\nFor example:\n\n```java\nList\u003cMap\u003cString, String\u003e\u003e transformation=new ArrayList\u003cMap\u003cString, String\u003e\u003e();\nMap\u003cString, String\u003e scale=new HashMap\u003c\u003e();\nscale.put(\"height\",\"300\");\nscale.put(\"width\",\"400\");\nscale.put(\"raw\", \"l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end\");\ntransformation.add(scale);\n\nMap\u003cString, Object\u003e options=new HashMap();\noptions.put(\"src\",\"https://ik.imagekit.io/your_imagekit_id/img/sample-video.mp4\");\noptions.put(\"transformation\", transformation);\n\nString url = ImageKit.getInstance().getUrl(options);\n```\n**Sample Result URL**\n```\nhttps://ik.imagekit.io/your_imagekit_id/img/sample-video.mp4?tr=h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end\n```\n\n**List of transformations**\n\nSee the complete list of [image](https://docs.imagekit.io/features/image-transformations) and [video](https://docs.imagekit.io/features/video-transformation) transformations supported in ImageKit. The SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. If the property does not match any of the following supported options, it is added as it is.\n\nIf you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter.\n\n| Supported Transformation Name | Translates to parameter |\n|-------------------------------|-------------------------|\n| height | h |\n| width | w |\n| aspectRatio | ar |\n| quality | q |\n| crop | c |\n| cropMode | cm |\n| x | x |\n| y | y |\n| focus | fo |\n| format | f |\n| radius | r |\n| background | bg |\n| border | b |\n| rotation | rt |\n| blur | bl |\n| named | n |\n| progressive | pr |\n| lossless | lo |\n| trim | t |\n| metadata | md |\n| colorProfile | cp |\n| defaultImage | di |\n| dpr | dpr |\n| effectSharpen | e-sharpen |\n| effectUSM | e-usm |\n| effectContrast | e-contrast |\n| effectGray | e-grayscale |\n| original | orig |\n| raw | `replaced by the parameter value` |\n\n\n## File Upload\n\nThe SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media library. It\naccepts an object of the `FileCreateRequest` class that contains all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload).\n\nThe constructor `FileCreateRequest` class requires `file` as (URL/Base64/Byte Array) and `file_name`. The method returns object of `Result` in case of successful, or it will throw custom exception in case of failure.\n\nSample usage\n\n```java\nString filePath = \"your-local-file-path\";\nString base64 = Utils.fileToBase64(new File(filePath));\nFileCreateRequest fileCreateRequest = new FileCreateRequest(base64, \"file_name.jpg\");\nString customCoordinates = \"10,10,20,20\";\nfileCreateRequest.setCustomCoordinates(customCoordinates);  // optional\nList\u003cString\u003e tags = new ArrayList\u003c\u003e();\ntags.add(\"Sample-tag\");\ntags.add(\"T-shirt\");\nfileCreateRequest.setTags(tags); // optional\nfileCreateRequest.setFileName(\"override_file_name.jpg\");  // optional\nfileCreateRequest.setFolder(\"sample-folder/nested-folder\");  // optional\nfileCreateRequest.setPrivateFile(false);  // optional\nfileCreateRequest.setUseUniqueFileName(true);  // optional\nList\u003cString\u003e responseFields=new ArrayList\u003c\u003e();\nresponseFields.add(\"tags\");\nresponseFields.add(\"customCoordinates\");\nfileCreateRequest.setResponseFields(responseFields); // optional\nJsonObject innerObject1 = new JsonObject();\ninnerObject1.addProperty(\"name\", \"remove-bg\");\ninnerObject1.add(\"options\", optionsInnerObject);\nJsonObject innerObject2 = new JsonObject();\ninnerObject2.addProperty(\"name\", \"google-auto-tagging\");\ninnerObject2.addProperty(\"minConfidence\", 10);\ninnerObject2.addProperty(\"maxTags\", 5);\nJsonArray jsonArray = new JsonArray();\njsonArray.add(innerObject1);\njsonArray.add(innerObject2);\nfileCreateRequest.setExtensions(jsonArray); // optional\nfileCreateRequest.setWebhookUrl(\"Your webhook url\"); // optional\nfileCreateRequest.setOverwriteFile(true); // optional\nfileCreateRequest.setOverwriteAITags(true); // optional\nfileCreateRequest.setOverwriteTags(true); // optional\nfileCreateRequest.setOverwriteCustomMetadata(true); // optional\nJsonObject jsonObjectCustomMetadata = new JsonObject();\njsonObjectCustomMetadata.addProperty(\"test1\", 10);\nfileCreateRequest.setCustomMetadata(jsonObjectCustomMetadata); // optional\nResult result = ImageKit.getInstance().upload(fileCreateRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\nIf the upload is successful, result will be there as an object of `Result` class that contains the same all the parameters received from ImageKit's servers.\n\nIf the upload fails, custom exception is thrown and `getMessage()` can be called to get the error message received from ImageKit's servers.\n\n\n## File Management\n\nThe SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api) to manage your files. This also returns `error` and `result`, the error will be `None` if API succeeds.\n\n**1. List \u0026 Search Files**\n\nAccepts an object of class `GetFileListRequest` specifying the parameters to be used to list and search files. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) can be passed via their setter functions to get the results.\n\n#### Applying Filters\nFilter out the files by specifying the parameters.\n\n```java\nString[] tags = new String[3];\ntags[0] = \"Software\";\ntags[1] = \"Developer\";\ntags[2] = \"Engineer\";\nGetFileListRequest getFileListRequest = new GetFileListRequest();\ngetFileListRequest.setType(\"file\");\ngetFileListRequest.setSort(\"ASC_CREATED\");\ngetFileListRequest.setPath(\"/\");\ngetFileListRequest.setFileType(\"all\");\ngetFileListRequest.setLimit(\"4\");\ngetFileListRequest.setSkip(\"1\");\ngetFileListRequest.setTags(tags);\nResultList resultList = ImageKit.getInstance().getFileList(getFileListRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultList);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultList.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultList.getResponseMetaData().getMap());\n```\n\n#### Advance Search\nIn addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and setting this generated string to the `GetFileListRequest` object using `setSearchQuery` function.\n\n```java\nGetFileListRequest getFileListRequest = new GetFileListRequest();\ngetFileListRequest.setSearchQuery(\"createdAt \u003e= '2d' OR size \u003c '2mb' OR format='png'\");\nResultList resultList = ImageKit.getInstance().getFileList(getFileListRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultList);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultList.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultList.getResponseMetaData().getMap());\n```\n\nDetailed documentation can be found here for [advance search queries](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#advanced-search-queries).\n\n**2. Get File Details**\n\nAccepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details)\n\n```java\nString fileId=\"your-file-id\";\nResult result=ImageKit.getInstance().getFileDetail(fileId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**3. Get File Versions**\n\nAccepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-versions).\n\n```java\nString fileId = \"62a04834c10d49825c6de9e8\";\nResultFileVersions resultFileVersions = ImageKit.getInstance().getFileVersions(fileId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultFileVersions);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultFileVersions.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultFileVersions.getResponseMetaData().getMap());\n```\n\n**4. Get File Version details**\n\nAccepts the file ID and version ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-version-details).\n\n```java\nString fileId = \"62a04834c10d49825c6de9e8\";\nString versionId = \"62a04834c10d49825c6de9e8\";\nResultFileVersionDetails resultFileVersionDetails = ImageKit.getInstance().getFileVersionDetails(fileId, versionId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultFileVersionDetails);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultFileVersionDetails.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultFileVersionDetails.getResponseMetaData().getMap());\n```\n\n**5. Update File Details**\n\nAccepts an object of class `FileUpdateRequest` specifying the parameters to be used to update file details. All parameters specified in the [documentation here] (https://docs.imagekit.io/api-reference/media-api/update-file-details) can be passed via their setter functions to get the results.\n\n```java\nList\u003cString\u003e tags = new ArrayList\u003c\u003e();\ntags.add(\"Software\");\ntags.add(\"Developer\");\ntags.add(\"Engineer\");\n\nList\u003cString\u003e aiTags = new ArrayList\u003c\u003e();\naiTags.add(\"Plant\");\nFileUpdateRequest fileUpdateRequest = new FileUpdateRequest(\"fileId\");\nfileUpdateRequest.setTags(tags);\nfileUpdateRequest.setRemoveAITags(aiTags);\nfileUpdateRequest.setWebhookUrl(\"https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e\");\n\nJsonObject optionsInnerObject = new JsonObject();\noptionsInnerObject.addProperty(\"add_shadow\", true);\noptionsInnerObject.addProperty(\"bg_color\", \"yellow\");\nJsonObject innerObject1 = new JsonObject();\ninnerObject1.addProperty(\"name\", \"remove-bg\");\ninnerObject1.add(\"options\", optionsInnerObject);\nJsonObject innerObject2 = new JsonObject();\ninnerObject2.addProperty(\"name\", \"google-auto-tagging\");\ninnerObject2.addProperty(\"minConfidence\", 15);\ninnerObject2.addProperty(\"maxTags\", 20);\nJsonArray jsonArray = new JsonArray();\njsonArray.add(innerObject1);\njsonArray.add(innerObject2);\n\nfileUpdateRequest.setExtensions(jsonArray);\nfileUpdateRequest.setCustomCoordinates(\"10,10,40,40\");\nJsonObject jsonObjectCustomMetadata = new JsonObject();\njsonObjectCustomMetadata.addProperty(\"test10\", 11);\nfileUpdateRequest.setCustomMetadata(jsonObjectCustomMetadata);\nResult result=ImageKit.getInstance().updateFileDetail(fileUpdateRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**6. Add tags**\n\nAccepts an object of class `TagsRequest` specifying the parameters to be used to add tags. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk) can be passed via their setter functions to get the results.\n\n```java\nList\u003cString\u003e fileIds = new ArrayList\u003c\u003e();\nfileIds.add(\"FileId\");\nList\u003cString\u003e tags = new ArrayList\u003c\u003e();\ntags.add(\"tag-to-add-1\");\ntags.add(\"tag-to-add-2\");\nResultTags resultTags=ImageKit.getInstance().addTags(new TagsRequest(fileIds, tags));\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultTags);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultTags.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultTags.getResponseMetaData().getMap());\n```\n\n**7. Remove tags**\n\nAccepts an object of class `TagsRequest` specifying the parameters to be used to remove tags. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk) can be passed via their setter functions to get the results.\n\n```java\nList\u003cString\u003e fileIds = new ArrayList\u003c\u003e();\nfileIds.add(\"FileId\");\nList\u003cString\u003e tags = new ArrayList\u003c\u003e();\ntags.add(\"tag-to-remove-1\");\ntags.add(\"tag-to-remove-2\");\nResultTags resultTags=ImageKit.getInstance().removeTags(new TagsRequest(fileIds, tags));\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultTags);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultTags.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultTags.getResponseMetaData().getMap());\n```\n\n**8. Remove AI tags**\n\nAccepts an object of class `AITagsRequest` specifying the parameters to be used to remove AI tags. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk) can be passed via their setter functions to get the results.\n\n```java\nList\u003cString\u003e fileIds = new ArrayList\u003c\u003e();\nfileIds.add(\"629f3de17eb0fe4053615450\");\nList\u003cString\u003e aiTags = new ArrayList\u003c\u003e();\naiTags.add(\"Rectangle\");\nAITagsRequest aiTagsRequest =new AITagsRequest();\naiTagsRequest.setFileIds(fileIds);\naiTagsRequest.setAITags(aiTags);\nResultTags resultTags = ImageKit.getInstance().removeAITags(aiTagsRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultTags);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultTags.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultTags.getResponseMetaData().getMap());\n```\n\n**9. Delete File**\n\nAccepts the file ID and delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file).\n\n```java\nString fileId=\"your-file-id\";\nResult result=ImageKit.getInstance().deleteFile(fileId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**10. Delete FileVersion**\n\nAccepts an object of class `DeleteFileVersionRequest` specifying the parameters to be used to delete file version. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file-version) can be passed via their setter functions to get the results.\n\n```java\nDeleteFileVersionRequest deleteFileVersionRequest = new DeleteFileVersionRequest();\ndeleteFileVersionRequest.setFileId(\"629d95278482ba129fd17c97\");\ndeleteFileVersionRequest.setVersionId(\"629d953ebd24e8ceca911a66\");\nResultNoContent resultNoContent = ImageKit.getInstance().deleteFileVersion(deleteFileVersionRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultNoContent);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getMap());\n```\n\n**11. Delete files (bulk)**\n\nAccepts the file IDs to delete files as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk).\n\n```java\nList\u003cString\u003e fileIds = new ArrayList\u003c\u003e();\nfileIds.add(\"your-file-id\");\nfileIds.add(\"your-file-id\");\nfileIds.add(\"your-file-id\");\n\nResultFileDelete result=ImageKit.getInstance().bulkDeleteFiles(fileIds);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**12. Copy file**\n\nAccepts an object of class `CopyFileRequest` specifying the parameters to be used to copy file. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/copy-file) can be passed via their setter functions to get the results.\n\n```java\nCopyFileRequest copyFileRequest = new CopyFileRequest();\ncopyFileRequest.setSourceFilePath(\"/w2_image.png\");\ncopyFileRequest.setDestinationPath(\"/Gallery/\");\ncopyFileRequest.setIncludeFileVersions(true);\nResultNoContent resultNoContent = ImageKit.getInstance().copyFile(copyFileRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultNoContent);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getMap());\n```\n\n**13. Move file**\n\nAccepts an object of class `MoveFileRequest` specifying the parameters to be used to move file. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/move-file) can be passed via their setter functions to get the results.\n\n```java\nMoveFileRequest moveFileRequest = new MoveFileRequest();\nmoveFileRequest.setSourceFilePath(\"/Gallery/w2_image.png\");\nmoveFileRequest.setDestinationPath(\"/\");\nResultNoContent resultNoContent = ImageKit.getInstance().moveFile(moveFileRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultNoContent);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getMap());\n```\n\n**14. Rename file**\n\nAccepts an object of class `RenameFileRequest` specifying the parameters to be used to rename file. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/rename-file) can be passed via their setter functions to get the results.\n\n```java\nRenameFileRequest renameFileRequest = new RenameFileRequest();\nrenameFileRequest.setFilePath(\"/w2_image.png\");\nrenameFileRequest.setNewFileName(\"w2_image_s.png\");\nrenameFileRequest.setPurgeCache(true);\nResultRenameFile resultRenameFile = ImageKit.getInstance().renameFile(renameFileRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultRenameFile);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultRenameFile.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultRenameFile.getResponseMetaData().getMap());\n```\n\n**15. Restore file Version**\n\nAccepts the fileId and versionId to restore file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/restore-file-version).\n\n```java\nResult result = ImageKit.getInstance().restoreFileVersion(\"fileId\", \"versionId\");\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**16. Create Folder**\n\nAccepts an object of class `CreateFolderRequest` specifying the parameters to be used to create folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/create-folder) can be passed via their setter functions to get the results.\n\n```java\nCreateFolderRequest createFolderRequest = new CreateFolderRequest();\ncreateFolderRequest.setFolderName(\"test1\");\ncreateFolderRequest.setParentFolderPath(\"/\");\nResultEmptyBlock resultEmptyBlock = ImageKit.getInstance().createFolder(createFolderRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultEmptyBlock);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultEmptyBlock.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultEmptyBlock.getResponseMetaData().getMap());\n```\n\n**17. Delete Folder**\n\nAccepts an object of class `DeleteFolderRequest` specifying the parameters to be used to delete folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/delete-folder) can be passed via their setter functions to get the results.\n\n```java\nDeleteFolderRequest deleteFolderRequest = new DeleteFolderRequest();\ndeleteFolderRequest.setFolderPath(\"/test1\");\nResultNoContent resultNoContent = ImageKit.getInstance().deleteFolder(deleteFolderRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultNoContent);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getMap());\n```\n\n**18. Copy Folder**\n\nAccepts an object of class `CopyFolderRequest` specifying the parameters to be used to copy folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/copy-folder) can be passed via their setter functions to get the results.\n\n```java\nCopyFolderRequest copyFolderRequest = new CopyFolderRequest();\ncopyFolderRequest.setSourceFolderPath(\"/Gallery/test\");\ncopyFolderRequest.setDestinationPath(\"/\");\nResultOfFolderActions resultOfFolderActions = ImageKit.getInstance().copyFolder(copyFolderRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultOfFolderActions);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultOfFolderActions.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultOfFolderActions.getResponseMetaData().getMap());\n```\n\n**19. Move Folder**\n\nAccepts an object of class `MoveFolderRequest` specifying the parameters to be used to move folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/move-folder) can be passed via their setter functions to get the results.\n\n```java\nMoveFolderRequest moveFolderRequest = new MoveFolderRequest();\nmoveFolderRequest.setSourceFolderPath(\"/Gallery/test\");\nmoveFolderRequest.setDestinationPath(\"/\");\nResultOfFolderActions resultOfFolderActions = ImageKit.getInstance().moveFolder(moveFolderRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultOfFolderActions);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultOfFolderActions.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultOfFolderActions.getResponseMetaData().getMap());\n```\n\n**20. Get Bulk Job Status**\n\nAccepts the jobId to get bulk job status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status).\n\n```java\nString jobId = \"629f44ac7eb0fe8173622d4b\";\nResultBulkJobStatus resultBulkJobStatus = ImageKit.getInstance().getBulkJobStatus(jobId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultBulkJobStatus);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultBulkJobStatus.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultBulkJobStatus.getResponseMetaData().getMap());\n```\n\n**21. Purge Cache**\n\nAccepts a full URL of the file for which the cache has to be cleared as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache).\n\n```java\nResultCache result=ImageKit.getInstance().purgeCache(\"https://ik.imagekit.io/imagekit-id/default-image.jpg\");\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**22. Purge Cache Status**\n\nAccepts a request ID and fetch purge cache status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status)\n\n```java\nString requestId=\"cache-requestId\";\nResultCacheStatus result=ImageKit.getInstance().getPurgeCacheStatus(requestId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**23. Get File Metadata**\n\nAccepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files)\n\n```java\nString fileId=\"your-file-id\";\nResultMetaData result=ImageKit.getInstance().getFileMetadata(fileId);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\nAnother way to get metadata from a remote file URL as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url). This file should be accessible over the ImageKit.io URL-endpoint.\n```java\nString url=\"Remote File URL\";\nResultMetaData result=ImageKit.getInstance().getRemoteFileMetadata(url);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(result);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(result.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(result.getResponseMetaData().getMap());\n```\n\n**24. Create CustomMetaDataFields**\n\nAccepts an object of class `CustomMetaDataFieldCreateRequest` specifying the parameters to be used to create cusomMetaDataFields. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) can be passed as-is with the correct values to get the results.\n\nCheck for the [Allowed Values In The Schema](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object).\n\n#### Examples:\n\n```java\nCustomMetaDataFieldSchemaObject schemaObject = new CustomMetaDataFieldSchemaObject();\nschemaObject.setType(\"Number\");\nschemaObject.setMinValue(10);\nschemaObject.setMaxValue(200);\nCustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest();\ncustomMetaDataFieldCreateRequest.setName(\"Name\");\ncustomMetaDataFieldCreateRequest.setLabel(\"Label\");\ncustomMetaDataFieldCreateRequest.setSchema(schemaObject);\nResultCustomMetaDataField resultCustomMetaDataField=ImageKit.getInstance().createCustomMetaDataFields(customMetaDataFieldCreateRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultCustomMetaDataField);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultCustomMetaDataField.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultCustomMetaDataField.getResponseMetaData().getMap());\n```\n\n- MultiSelect type Exmample:\n\n```java\nList\u003cObject\u003e objectList = new ArrayList\u003c\u003e();\nobjectList.add(\"small\");\nobjectList.add(30);\nobjectList.add(40);\nobjectList.add(true);\n\nList\u003cObject\u003e defaultValueObject = new ArrayList\u003c\u003e();\ndefaultValueObject.add(\"small\");\ndefaultValueObject.add(30);\ndefaultValueObject.add(true);\nCustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject();\ncustomMetaDataFieldSchemaObject.setType(\"MultiSelect\");\ncustomMetaDataFieldSchemaObject.setValueRequired(true);                 // optional\ncustomMetaDataFieldSchemaObject.setDefaultValue(defaultValueObject);    // required if isValueRequired set to true\ncustomMetaDataFieldSchemaObject.setSelectOptions(objectList);\nCustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest();\ncustomMetaDataFieldCreateRequest.setName(\"Name-MultiSelect\");\ncustomMetaDataFieldCreateRequest.setLabel(\"Label-MultiSelect\");\ncustomMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject);\n\nResultCustomMetaDataField resultCustomMetaDataField = ImageKit.getInstance()\n      .createCustomMetaDataFields(customMetaDataFieldCreateRequest);\n```\n\n- Date type Exmample:\n\n```java\nCustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject();\ncustomMetaDataFieldSchemaObject.setType(\"Date\");\ncustomMetaDataFieldSchemaObject.setValueRequired(true);                          // optional\ncustomMetaDataFieldSchemaObject.setDefaultValue(\"2022-11-30T10:11:10+00:00\");    // required if isValueRequired set to true\ncustomMetaDataFieldSchemaObject.setMinValue(\"2022-11-30T10:11:10+00:00\");\ncustomMetaDataFieldSchemaObject.setMaxValue(\"2022-12-30T10:11:10+00:00\");\n\nCustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest();\ncustomMetaDataFieldCreateRequest.setName(\"Name\");\ncustomMetaDataFieldCreateRequest.setLabel(\"Label\");\ncustomMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject);\n\nResultCustomMetaDataField resultCustomMetaDataField = ImageKit.getInstance()\n       .createCustomMetaDataFields(customMetaDataFieldCreateRequest);\n```\n\n\n**25. Get CustomMetaDataFields**\n\nAccepts the includeDeleted boolean and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field)\n\n```java\nResultCustomMetaDataFieldList resultCustomMetaDataFieldList=ImageKit.getInstance().getCustomMetaDataFields(false);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultCustomMetaDataFieldList);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultCustomMetaDataFieldList.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultCustomMetaDataFieldList.getResponseMetaData().getList());\nSystem.out.println(resultCustomMetaDataFieldList.getResultCustomMetaDataFields());\n```\n\n**26. Edit CustomMetaDataFields**\n\nAccepts an ID of customMetaDataField and object of class `CustomMetaDataFieldUpdateRequest` specifying the parameters to be used to edit cusomMetaDataFields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field).\n\n```java\nCustomMetaDataFieldSchemaObject schemaObject = new CustomMetaDataFieldSchemaObject();\nschemaObject.setMinValue(10);\nschemaObject.setMaxValue(200);\n\nCustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest();\ncustomMetaDataFieldUpdateRequest.setId(\"id\");\ncustomMetaDataFieldUpdateRequest.setLabel(\"label\");\ncustomMetaDataFieldUpdateRequest.setSchema(schemaObject);\nResultCustomMetaDataField resultCustomMetaDataField=ImageKit.getInstance().updateCustomMetaDataFields(customMetaDataFieldUpdateRequest);\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultCustomMetaDataField);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultCustomMetaDataField.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultCustomMetaDataField.getResponseMetaData().getMap());\n```\n\n**27. Delete CustomMetaDataFields**\n\nAccepts the id to delete the customMetaDataFields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field).\n\n```java\nResultNoContent resultNoContent=ImageKit.getInstance().deleteCustomMetaDataField(\"id\");\nSystem.out.println(\"======FINAL RESULT=======\");\nSystem.out.println(resultNoContent);\nSystem.out.println(\"Raw Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getRaw());\nSystem.out.println(\"Map Response:\");\nSystem.out.println(resultNoContent.getResponseMetaData().getMap());\n```\n\n## Utility functions\n\nWe have included the following commonly used utility functions in this package.\n\n**Authentication parameter generation**\n\nIn case you are looking to implement client-side file upload, you are going to need a token, expiry timestamp, and a valid signature for that upload. The SDK provides a simple method that you can use in your code to generate these\nauthentication parameters for you.\n\n\u003cem\u003eNote: The Private API Key should never be exposed in any client-side code. You must always generate these authentications\n parameters on the server-side\u003c/em\u003e\n\nauthentication\n\n```java\nMap\u003cString,String\u003e authenticationParams = ImageKit.getInstance().getAuthenticationParameters(token, expire);\n```\n\nReturns Map object of this json\n```json\n{\n    \"token\": \"unique_token\",\n    \"expire\": \"valid_expiry_timestamp\",\n    \"signature\": \"generated_signature\"\n}\n```\n\nBoth the `token` and `expire` parameters are optional. If not specified, the SDK uses the uuid to generate a random\ntoken and also generates a valid expiry timestamp internally. The value of the token and expire used to generate the\nsignature are always returned in the response, no matter if they are provided as an input to this method or not.\n\n**Distance calculation between two pHash values**\n\nPerceptual hashing allows you to construct a hash value that uniquely identifies an input image based on the contents\nof an image. [imagekit.io metadata API](https://docs.imagekit.io/api-reference/metadata-api) returns the pHash\nvalue of an image in the response. You can use this value to find a duplicate (or similar) images by calculating the distance between the two images.\n\n\nThis SDK exposes phash_distance function to calculate the distance between two pHash value. It accepts two pHash hexadecimal\nstrings and returns a numeric value indicative of the level of difference between the two images.\n\n```java\nint calculateDistance(){\n    // fetch metadata of two uploaded image files\n    ...\n    // extract pHash strings from both: say 'first_hash' and 'second_hash'\n    ...\n    // calculate the distance between them:\n\n    int distance = ImageKit.getInstance().pHashDistance(first_hash, second_hash);\n    return distance;\n}\n```\n\n**Distance calculation examples**\n```java\nImageKit.getInstance().pHashDistance(\"f06830ca9f1e3e90\", \"f06830ca9f1e3e90\");\n// output: 0 (ame image)\n\nImageKit.getInstance().pHashDistance(\"2d5ad3936d2e015b\", \"2d6ed293db36a4fb\");\n// output: 17 (similar images)\n\nImageKit.getInstance().pHashDistance(\"a4a65595ac94518b\", \"7838873e791f8400\");\n// output: 37 (dissimilar images)\n```\n\n**HTTP response metadata of Internal API**\n\nHTTP response metadata of the internal API call can be accessed using the getResponseMetaData function on the Result (or ResultList, ResultCache etc.) object. Example:\n\n```java\nResult result = ImageKit.getInstance().upload(fileCreateRequest);\nresult.getResponseMetaData().getRaw();\nresult.getResponseMetaData().getHeaders();\nresult.getResponseMetaData().getHttpStatusCode();\n```\n\n## Sample Code Instruction\n\n**1. First clone this repository to your system using git.**\n```shell script\ngit clone https://github.com/imagekit-developer/imagekit-java.git\n```\n**2. Open project in your favorite Java IDE that can supports Gradle dependency management or you can use Terminal/Command Prompt.**\n\n**3. Goto `src/main/resources` directory.**\n\n**4. Rename file `config.sample.properties` to `config.properties`.**\n\n**5. Edit `config.properties` and write values of given keys.**\n```properties\nUrlEndpoint=your_url_endpoint\nPrivateKey=your_private_key\nPublicKey=your_public_key\n```\n\n**5. You will find `App.java` in `src/main/java/io/imagekit/sampleapp/` directory. Edit program as you need, then run `App.java`. If you are using CLI Tool (Terminal/Command Prompt) Then Open Project in CLI and execute using gradle**\n```shell\ncd imagekit-java\n./gradlew run\n```\n* Run test case:\n```shell\n./gradlew imagekit-sdk:test\n```\n* Build ImageKit SDK:\n```shell\n./gradlew imagekit-sdk:clean\n./gradlew imagekit-sdk:build\n# You will find jar in \"imagekit-sdk/build/libs/\" directory.\n```\n\n## Handling errors\nCatch and respond to invalid data, internal problems, and more.\n\nImagekit Java SDK raise exceptions for many reasons, such as not found, invalid parameters, authentication errors, and internal server error. We recommend writing code that gracefully handles all possible API exceptions.\n\n#### Example:\n\n```java\ntry {\n  // Use ImageKit's SDK to make requests...\n} catch (BadRequestException e) {\n  // Missing or Invalid parameters were supplied to Imagekit.io's API\n  System.out.println(\"Status is: \" + e.getResponseMetaData().getHttpStatusCode());\n  System.out.println(\"Message is: \" + e.getMessage());\n  System.out.println(\"Headers are: \" + e.getResponseMetaData().getHeaders());\n  System.out.println(\"Raw body is: \" + e.getResponseMetaData().getRaw());\n  System.out.println(\"Mapped body is: \" + e.getResponseMetaData().getMap());\n} catch (UnauthorizedException e) {\n  // No valid API key was provided.\n} catch (ForbiddenException e) {\n  // Can be for the following reasons: \n  // ImageKit could not authenticate your account with the keys provided.\n  // An expired key (public or private) was used with the request.\n  // The account is disabled.\n  // If you are using the upload API, the total storage limit (or upload limit) is exceeded.\n} catch (TooManyRequestsException e) {\n  // Too many requests made to the API too quickly\n} catch (InternalServerException e) {\n  // Something went wrong with ImageKit.io API.\n} catch (PartialSuccessException e) {\n  // Error cases on partial success.\n} catch (NotFoundException e) {\n  // If any of the field or parameter is not found in data \n} catch (UnknownException e) {\n  // Something else happened, which can be unrelated to imagekit, reason will be indicated in the message field\n}\n```\n\n## Supporttim\nFor any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io]()\n\n\n## Links\n\n* [Documentation](https://docs.imagekit.io/)\n* [Main Website](https://imagekit.io/)\n\n\n## License\nReleased under the MIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagekit-developer%2Fimagekit-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimagekit-developer%2Fimagekit-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagekit-developer%2Fimagekit-java/lists"}