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
+27-9Lines changed: 27 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,12 @@ Javascript SDK for [ImageKit](https://imagekit.io/) provides URL generation for
14
14
15
15
ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). 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.
16
16
17
+
## Changelog - SDK Version 2.0.0
18
+
### Breaking changes
19
+
**1. Authentication Process Update:**
20
+
* Previously, when using client side file upload, the SDK required the `publicKey` and `authenticationEndpoint` parameters during SDK initialization to fetch security parameters (`signature`, `token`, and `expire`).
21
+
* In version 2.0.0, we've updated the authentication process for the SDK. As a user of the SDK, you are now responsible for generating the security parameters (`signature`, `token`, and `expire`) yourself. This means you no longer need to provide the `authenticationEndpoint`. When using the SDK's upload method, make sure to pass these security parameters explicitly along with other [upload options](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload). For guidance on generating these security parameters, please refer to the documentation available [here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
22
+
17
23
## Installation
18
24
19
25
### Using npm
@@ -59,12 +65,11 @@ var imagekit = new ImageKit({
59
65
});
60
66
```
61
67
62
-
`publicKey`and `authenticationEndpoint` parameters are required if you want to use the SDK for client-side file upload. You can get these parameters from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers
68
+
`publicKey`parameter is required if you want to use the SDK for client-side file upload. You can get this parameter from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers
@@ -261,9 +266,7 @@ The SDK provides a simple interface using the `.upload()` method to upload files
261
266
262
267
The `upload()` method requires mandatory `file` and the `fileName` parameter. In addition, it accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
263
268
264
-
Also, ensure that you have specified `authenticationEndpoint` during SDK initialization. The SDK makes an HTTP GET request to this endpoint and expects a JSON response with three fields, i.e. `signature`, `token`, and `expire`. In addition, the SDK adds a query parameter `t` with a random value to ensure that the request URL is unique and the response is not cached in [Safari iOS](https://github.com/imagekit-developer/imagekit-javascript/issues/59). Your backend can ignore this query parameter.
265
-
266
-
[Learn how to implement authenticationEndpoint](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#how-to-implement-authenticationendpoint-endpoint) on your server.
269
+
Also before making an upload request, please ensure you have generated mandatory security parameters: `signature`, `token`, and `expire`. To generate these security parameters, refer to the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload). Obtain the parameters using a secure method and pass them, along with the mandatory `file` and `fileName` parameters, to the `upload()` method.
267
270
268
271
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/client-side-file-upload).
269
272
@@ -277,13 +280,12 @@ You can pass other parameters supported by the ImageKit upload API using the sam
authenticationEndpoint should be implemented on your server. Learn more here - https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#how-to-implement-authenticationendpoint-endpoint
varAUTH_INVALID_RESPONSE="Invalid response from authenticationEndpoint. The SDK expects a JSON response with three fields i.e. signature, token and expire."
37
37
var statusEl =document.getElementById("status");
38
38
statusEl.innerHTML="Uploading...";
39
39
@@ -50,41 +50,72 @@ html
50
50
}
51
51
});
52
52
53
-
imagekit.upload({
54
-
xhr: customXHR, // Use this if you want to track upload progress
* Pass the full URL, for example - https://www.example.com/rest-of-the-image-path.jpg.
14
14
*/
15
15
file: string|Blob|File;
16
+
/**
17
+
* HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. This should be in lowercase.
18
+
* Warning: Signature must be calculated on the server-side. This field is required for authentication when uploading a file from the client-side.
19
+
*/
20
+
signature: string;
21
+
/**
22
+
* A unique value generated by the client, which will be used by the ImageKit.io server to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions.
23
+
* Note: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.
24
+
*/
25
+
token: string;
26
+
/**
27
+
* The time until your signature is valid. It must be a Unix time in less than 1 hour into the future. It should be in seconds.
28
+
*/
29
+
expire: number;
16
30
/**
17
31
* The name with which the file has to be uploaded.
0 commit comments