Skip to content

Commit e19d455

Browse files
committed
readme update
1 parent 9815eb9 commit e19d455

File tree

1 file changed

+30
-44
lines changed

1 file changed

+30
-44
lines changed

README.md

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# ImageKit Java SDK
32

43
[![Java CI](https://github.com/imagekit-developer/imagekit-java/workflows/Java%20CI/badge.svg)](https://github.com/imagekit-developer/imagekit-java)
@@ -33,13 +32,13 @@ Table of contents -
3332
Step 1. Add the JitPack repository to your build file
3433
```
3534
allprojects {
36-
repositories {
37-
...
38-
maven { url 'https://jitpack.io' }
39-
}
35+
repositories {
36+
...
37+
maven { url 'https://jitpack.io' }
38+
}
4039
}
4140
```
42-
Step 2. Add the dependency on project's `build.gradle`:
41+
Step 2. Add the dependency on the project's `build.gradle`:
4342
```
4443
dependencies {
4544
implementation 'com.github.imagekit-developer:imagekit-java:2.0.0'
@@ -55,7 +54,7 @@ Step 1. Add the JitPack repository to your build file
5554
</repository>
5655
</repositories>
5756
```
58-
Step 2. Add the dependency in POM file:
57+
Step 2. Add the dependency in the POM file:
5958
```
6059
<dependency>
6160
<groupId>com.github.imagekit-developer</groupId>
@@ -66,15 +65,15 @@ Step 2. Add the dependency in POM file:
6665

6766
## Initialization
6867

69-
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.
68+
**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.
7069

7170
```editorconfig
7271
# Put essential values of keys [UrlEndpoint, PrivateKey, PublicKey]
7372
UrlEndpoint=<-YOUR-ENDPOINT-URL-HERE->
7473
PrivateKey=<-YOUR-PRIVATE-KEY-HERE->
7574
PublicKey=<-YOUR-PUBLIC-KEY-HERE->
7675
```
77-
Step 2. Then you need to initialize ImageKit with that configuration.
76+
**Step 2**. Then you need to initialize ImageKit with that configuration.
7877

7978
```java
8079
import io.imagekit.sdk.ImageKit;
@@ -110,47 +109,44 @@ You can use this Java SDK for 3 different kinds of methods:
110109
* URL generation
111110
* file upload
112111
* file management
113-
*
112+
114113
The usage of the SDK has been explained below.
115114

116115
## Change log
117-
This document presents a list of changes that break existing functionality of previous versions. We try our best to minimize these disruptions, but sometimes they are unavoidable and they will be in major versions.
116+
This 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.
118117

119118
### Breaking History:
120119

121120
Changes from 1.0.3 -> 2.0.0 are listed below
122121

123-
1. Result object raw and getMap() properties:
122+
1. Result raw object and getMap() properties:
124123

125124
**What changed**
126125
- raw and getMap() has been deprecated.
127126

128127
**Who is affected?**
129-
- This affects any development that uses the raw or getMap() from response object of APIs that is Result object.
128+
- This affects any development that uses the raw or getMap() from the response object of APIs and Result object.
130129

131130
**How should I update my code?**
132-
- If you still need to use raw and getMap(), write it with using it with result's internal property such as result.getResponseMetaData().getRaw().
131+
- If you still need to use raw and getMap(), do this `result.getResponseMetaData().getRaw()`.
133132

134133
2. Result object message and isSuccessful boolean properties:
135134

136135
**What changed**
137-
- message and isSuccessful has been replaced with custom exceptions according to response code.
136+
- message and isSuccessful have been replaced with custom exceptions according to response code.
138137

139138
**Who is affected?**
140139
- This affects any development that uses the message or isSuccessful from response object of APIs that is Result object.
141140

142141
**How should I update my code?**
143-
- If you still need to use message it will be there in custom exception and could be raised isSuccessful properties in your own code from status code which is coming in the response or custom exception.
142+
- If you still need to use message it will be there in the custom exception and could be raised isSuccessful properties in your own code from status code that is coming in the response or custom exception.
144143

145144

146145
## URL generation
147146

148147
**1. Using image path and URL-endpoint**
149148

150-
This method allows you to create a URL using the path where the image exists and the URL-endpoint you want to use to access the image. You can refer to the documentation
151-
[here](https://docs.imagekit.io/integration/url-endpoints) to read more about URL endpoints
152-
in ImageKit and the section about [image origins](https://docs.imagekit.io/integration/configure-origin) to understand
153-
about paths with different kinds of origins.
149+
This 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.
154150

155151
```java
156152
Map<String, String> queryParam=new HashMap<>();
@@ -176,9 +172,7 @@ https://ik.imagekit.io/your_imagekit_id/tr:w-400,h-600/default-image.jpg?v=123
176172
```
177173

178174
**2. Using full image URL**
179-
This method allows you to add transformation parameters to an existing complete URL that is already mapped to ImageKit
180-
using the `src` parameter. This method should be used if you have the complete image URL mapped to ImageKit stored in your
181-
database.
175+
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.
182176

183177
```java
184178
List<Map<String, String>> transformation=new ArrayList<Map<String, String>>();
@@ -205,13 +199,13 @@ The ```.getUrl()``` method accepts the following parameters
205199

206200
| Option | Description |
207201
| :---------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
208-
| urlEndpoint | Optional. `(Type: String)` 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/ |
202+
| 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/ |
209203
| 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. |
210204
| 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. |
211205
| transformation | Optional. `(Type: List<Map<String,String>>)` 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. |
212-
| 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. |
213-
| queryParameters | Optional. `(Type: Map<String, String>)` 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 parameter to your URLs. |
214-
| 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 are creating the URL with the `url_endpoint` and `path` parameters, and not with the `src` parameter. |
206+
| 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. |
207+
| queryParameters | Optional. `(Type: Map<String, String>)` 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. |
208+
| 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. |
215209
| 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. |
216210

217211

@@ -241,7 +235,7 @@ Sample Result URL -
241235
https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300&w-400:rt-90
242236
```
243237

244-
**2. Sharpening and contrast transforms and a progressive JPG image**
238+
**2. Sharpening and contrast transform and a progressive JPG image**
245239

246240
There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation)
247241
that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify
@@ -292,11 +286,9 @@ https://ik.imagekit.io/your_imagekit_id/tr:h-600,w-400/default-image.jpg?ik-t=15
292286

293287
**List of transformations**
294288

295-
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).
296-
The SDK gives a name to each transformation parameter, making the code simpler, making the code more straightforward and readable.
297-
If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the
298-
transformation code from ImageKit docs as the name when using in the ```url``` function.
289+
See 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.
299290

291+
If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter.
300292

301293
| Supported Transformation Name | Translates to parameter |
302294
|-------------------------------|-------------------------|
@@ -362,12 +354,9 @@ transformation code from ImageKit docs as the name when using in the ```url``` f
362354
## File Upload
363355

364356
The SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media library. It
365-
accepts an object of `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).
357+
accepts 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).
366358

367-
The constructor `FileCreateRequest` class requires `file` as (URL/Base64/Byte Array) and `file_name` if `file` is byte array then it's require another parameter named `mediaType` to upload a file. The method returns object of `Result` class. It contains method `isSuccessful()` (return boolean), `getMessage()` for error message and other file parameter responsed by server.
368-
ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to
369-
specify tags for a file at the time of upload use the tags parameter as specified in the
370-
[documentation here](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload)
359+
The constructor `FileCreateRequest` class requires `file` as (URL/Base64/Byte Array) and `file_name`. If `file` is byte array then it's require another parameter named `mediaType` to upload a file. The method returns object of `Result` class. It contains method `isSuccessful()` (return boolean), `getMessage()` for error message and other file parameter responsed by server.
371360

372361
Sample usage
373362

@@ -417,21 +406,18 @@ System.out.println("Map Response:");
417406
System.out.println(result.getResponseMetaData().getMap());
418407
```
419408

420-
If the upload is successful, `getMessage()` will be `None`, and the result will be an object of `Result` class that contains the same all the parameters received from ImageKit's servers and `isSuccessful()` will return true.
409+
If the upload is successful, `getMessage()` will be `None`, and the result will be an object of `Result` class that contains the same all the parameters received from ImageKit's servers, and `isSuccessful()` will return true.
421410

422-
If the upload fails, `getMessage()` will contain the same error message received from ImageKit's servers and `isSuccessful()` will return false.
411+
If the upload fails, `getMessage()` will contain the same error message received from ImageKit's servers, and `isSuccessful()` will return false.
423412

424413

425414
## File Management
426415

427-
The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api)
428-
to manage your files. This also returns `error` and `result`, the error will be `None` if API succeeds.
416+
The 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.
429417

430418
**1. List & Search Files**
431419

432-
Accepts an object specifying the parameters to be used to list and search files. All parameters specified
433-
in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) can be passed as-is with the
434-
correct values to get the results.
420+
Accepts an object 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 as-is with the correct values to get the results.
435421

436422
```java
437423
String[] tags = new String[3];

0 commit comments

Comments
 (0)