You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-23Lines changed: 21 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ npm install imagekit
33
33
34
34
## Initialization
35
35
36
-
```
36
+
```js
37
37
var ImageKit =require("imagekit");
38
38
39
39
var imagekit =newImageKit({
@@ -56,7 +56,7 @@ You can use this NodeJS SDK for three different kinds of functions - URL generat
56
56
57
57
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.
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.
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.
**3. Signed URL that expires in 300 seconds with the default URL endpoint and other query parameters**
152
-
```
152
+
```js
153
153
var imageURL =imagekit.url({
154
154
path :"/default-image.jpg",
155
155
queryParameters : {
@@ -239,7 +239,7 @@ The SDK provides a simple interface using the `.upload()` method to upload files
239
239
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).
240
240
241
241
Sample usage
242
-
```
242
+
```js
243
243
// Using Callback Function
244
244
245
245
imagekit.upload({
@@ -275,7 +275,7 @@ The SDK provides a simple interface for all the [media APIs mentioned here](http
275
275
276
276
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.
277
277
278
-
```
278
+
```js
279
279
// Using Callback Function
280
280
281
281
imagekit.listFiles({
@@ -303,7 +303,7 @@ imagekit.listFiles({
303
303
304
304
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).
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).
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.
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.
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.
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.
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)
@@ -477,12 +475,12 @@ In case you are looking to implement client-side file upload, you are going to n
477
475
478
476
*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*
479
477
480
-
```
478
+
```js
481
479
var authenticationParameters =imagekit.getAuthenticationParameters(token, expire);
482
480
```
483
481
484
482
Returns
485
-
```
483
+
```js
486
484
{
487
485
token :"unique_token",
488
486
expire :"valid_expiry_timestamp",
@@ -498,7 +496,7 @@ Perceptual hashing allows you to construct a hash value that uniquely identifies
498
496
499
497
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.
500
498
501
-
```
499
+
```js
502
500
constcalculateDistance= () => {
503
501
// asynchronously fetch metadata of two uploaded image files
0 commit comments