Skip to content

Commit ed5ff38

Browse files
docs: update to make it more readable
* Better readability with syntax highlighting * Fixed small typo on `deleteFile` method
1 parent b6983e6 commit ed5ff38

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

README.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ npm install imagekit
3333

3434
## Initialization
3535

36-
```
36+
```js
3737
var ImageKit = require("imagekit");
3838

3939
var imagekit = new ImageKit({
@@ -56,7 +56,7 @@ You can use this NodeJS SDK for three different kinds of functions - URL generat
5656

5757
This method allows you to create a URL using the `path` where the image exists and the URL endpoint (`urlEndpoint`) you want to use to access the image. You can refer to the documentation [here](https://docs.imagekit.io/integration/url-endpoints) to read more about URL endpoints in ImageKit and the section about [image origins](https://docs.imagekit.io/integration/configure-origin) to understand about paths with different kinds of origins.
5858

59-
```
59+
```js
6060
var imageURL = imagekit.url({
6161
path : "/default-image.jpg",
6262
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/endpoint/",
@@ -78,7 +78,7 @@ https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/default-image.jp
7878
This method allows you to add transformation parameters to an existing, complete URL that is already mapped to ImageKit using the `src` parameter. Use this method if you have the absolute image URL stored in your database.
7979

8080

81-
```
81+
```js
8282
var imageURL = imagekit.url({
8383
src : "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
8484
transformation : [{
@@ -111,7 +111,7 @@ The `.url()` method accepts the following parameters
111111
#### Examples of generating URLs
112112

113113
**1. Chained Transformations as a query parameter**
114-
```
114+
```js
115115
var imageURL = imagekit.url({
116116
path : "/default-image.jpg",
117117
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/endpoint/",
@@ -132,7 +132,7 @@ https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-
132132

133133
There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify the value as "-" in the transformation object. Otherwise, specify the value that you want to be added to this transformation.
134134

135-
```
135+
```js
136136
var imageURL = imagekit.url({
137137
src : "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
138138
transformation : [{
@@ -149,7 +149,7 @@ https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg%2Cpr
149149
```
150150

151151
**3. Signed URL that expires in 300 seconds with the default URL endpoint and other query parameters**
152-
```
152+
```js
153153
var imageURL = imagekit.url({
154154
path : "/default-image.jpg",
155155
queryParameters : {
@@ -239,7 +239,7 @@ The SDK provides a simple interface using the `.upload()` method to upload files
239239
The `upload()` method requires at least the `file` and the `fileName` parameter to upload a file and returns a callback with the `error` and `result` as arguments. You can pass other parameters supported by the 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).
240240

241241
Sample usage
242-
```
242+
```js
243243
// Using Callback Function
244244

245245
imagekit.upload({
@@ -275,7 +275,7 @@ The SDK provides a simple interface for all the [media APIs mentioned here](http
275275

276276
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.
277277

278-
```
278+
```js
279279
// Using Callback Function
280280

281281
imagekit.listFiles({
@@ -303,7 +303,7 @@ imagekit.listFiles({
303303

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

306-
```
306+
```js
307307
// Using Callback Function
308308

309309
imagekit.getFileDetails("file_id", function(error, result) {
@@ -326,7 +326,7 @@ imagekit.getFileDetails("file_id")
326326

327327
Accepts 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).
328328

329-
```
329+
```js
330330
// Using Callback Function
331331

332332
imagekit.getFileMetadata("file_id", function(error, result) {
@@ -349,7 +349,7 @@ imagekit.getFileMetadata("file_id")
349349

350350
Update parameters associated with the file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/update-file-details). The first argument to the `updateFileDetails` method is the file ID, and a second argument is an object with the parameters to be updated.
351351

352-
```
352+
```js
353353
// Using Callback Function
354354

355355
imagekit.updateFileDetails("file_id", {
@@ -377,8 +377,7 @@ imagekit.updateFileDetails("file_id", {
377377

378378
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.
379379

380-
```
381-
380+
```js
382381
// Using Callback Function
383382

384383
imagekit.deleteFile("file_id", function(error, result) {
@@ -389,7 +388,7 @@ imagekit.deleteFile("file_id", function(error, result) {
389388

390389
// Using Promises
391390

392-
imagekit.deleteFile("file_id"})
391+
imagekit.deleteFile("file_id")
393392
}).then(response => {
394393
console.log(response);
395394
}).catch(error => {
@@ -401,8 +400,7 @@ imagekit.deleteFile("file_id"})
401400

402401
Delete multiple files as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk). The method accepts an array of file IDs of the files that have to be deleted.
403402

404-
```
405-
403+
```js
406404
// Using Callback Function
407405

408406
imagekit.bulkDeleteFiles(["fileIds"], function(error, result) {
@@ -425,7 +423,7 @@ imagekit.bulkDeleteFiles(["fileIds"])
425423

426424
Programmatically issue a cache clear request as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache). Accepts the full URL of the file for which the cache has to be cleared.
427425

428-
```
426+
```js
429427
// Using Callback Function
430428

431429
imagekit.purgeCache("full_url", function(error, result) {
@@ -448,7 +446,7 @@ imagekit.purgeCache("full_url")
448446

449447
Get the purge cache request status using the request ID returned when a purge cache request gets submitted as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status)
450448

451-
```
449+
```js
452450
// Using Callback Function
453451

454452
imagekit.getPurgeCacheStatus("cache_request_id", function(error, result) {
@@ -477,12 +475,12 @@ In case you are looking to implement client-side file upload, you are going to n
477475

478476
*Note: The Private API Key should never be exposed in any client-side code. You must always generate these authentication parameters on the server-side*
479477

480-
```
478+
```js
481479
var authenticationParameters = imagekit.getAuthenticationParameters(token, expire);
482480
```
483481

484482
Returns
485-
```
483+
```js
486484
{
487485
token : "unique_token",
488486
expire : "valid_expiry_timestamp",
@@ -498,7 +496,7 @@ Perceptual hashing allows you to construct a hash value that uniquely identifies
498496

499497
This SDK exposes `pHashDistance` function to calculate the distance between two pHash values. It accepts two pHash hexadecimal strings and returns a numeric value indicative of the level of difference between the two images.
500498

501-
```
499+
```js
502500
const calculateDistance = () => {
503501
// asynchronously fetch metadata of two uploaded image files
504502
// ...
@@ -511,7 +509,7 @@ const calculateDistance = () => {
511509
```
512510
#### Distance calculation examples
513511

514-
```
512+
```js
515513
imagekit.pHashDistance('f06830ca9f1e3e90', 'f06830ca9f1e3e90');
516514
// output: 0 (same image)
517515

@@ -543,4 +541,4 @@ For any feedback or to report any issues or general implementation support, plea
543541

544542
## License
545543

546-
Released under the MIT license.
544+
Released under the MIT license.

0 commit comments

Comments
 (0)