diff --git a/README.md b/README.md index ed7783b..f356415 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,7 @@ import { IKImage, IKVideo, IKContext, IKUpload } from 'imagekitio-react' } ] }} + checks={`"file.size" < "1mb"`} // To run server side checks before uploading files. Notice the quotes around file.size and 1mb. /> ``` @@ -620,12 +621,13 @@ The SDK provides the `IKUpload` component to upload files to the [ImageKit Media | onUploadStart | Function callback | Optional. Called before the upload is started. The first and only argument is the HTML input's change event | | onUploadProgress | Function callback | Optional. Called while an upload is in progress. The first and only argument is the ProgressEvent | | validateFile | Function callback | Optional. This function accepts the `File` object as an argument and exoects a Boolean return value. This is called before the upload is started to run custom validation. The first and only argument is the file selected for upload. If the callback returns `true`, the upload is allowed to continue. But, if it returns `false`, the upload is not done | -| overrideParameters | Function callback | Optional. This function accepts the `File` object as an argument and should return a JSON value, e.g., `{fileName: "new-file-name.jpg"}.` Use this to programmatically override `fileName`, `useUniqueFileName`, `tags`, `folder`, `isPrivateFile`, `customCoordinates`, `extensions`, `webhookUrl`, `overwriteFile`, `overwriteAITags`, `overwriteTags`, `overwriteCustomMetadata`, `customMetadata`, and `transformation` parameters. | +| overrideParameters | Function callback | Optional. This function accepts the `File` object as an argument and should return a JSON value, e.g., `{fileName: "new-file-name.jpg"}.` Use this to programmatically override `fileName`, `useUniqueFileName`, `tags`, `folder`, `isPrivateFile`, `customCoordinates`, `extensions`, `webhookUrl`, `overwriteFile`, `overwriteAITags`, `overwriteTags`, `overwriteCustomMetadata`, `customMetadata`, `transformation`, and `checks` parameters. | | onSuccess | Function callback | Optional. Called if the upload is successful. The first and only argument is the response JSON from the upload API. The request-id, response headers, and HTTP status code are also accessible using the $ResponseMetadata key that is exposed from the [javascript sdk](https://github.com/imagekit-developer/imagekit-javascript#access-request-id-other-response-headers-and-http-status-code) | | onError | Function callback | Optional. Called if upload results in an error. The first and only argument is the error received from the upload API | | urlEndpoint | String | Optional. If not specified, the URL-endpoint specified in the parent `IKContext` component is used. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/ | | publicKey | String | Optional. If not specified, the `publicKey` specified in the parent `IKContext` component is used. | | authenticator | ()=>Promise<{signature:string,token:string,expiry:number}> | Optional. If not specified, the `authenticator` specified in the parent `IKContext` component is used. | +| checks | String | Optional. Run server-side checks before uploading files. For example, `"file.size" < "1mb"` will check if the file size is less than 1 MB. Check [Upload API docs](https://imagekit.io/docs/api-reference/upload-file/upload-file#upload-api-checks) to learn more. Notice the quotes around `file.size` and `1mb`; otherwise, you will get an error `Your request contains invalid syntax for the checks parameter.` | > Make sure that you have specified `authenticator` and `publicKey` in `IKUpload` or in the parent `IKContext` component as a prop. The authenticator expects an asynchronous function that resolves with an object containing the necessary security parameters i.e `signature`, `token`, and `expire`. diff --git a/package-lock.json b/package-lock.json index 6ec5f1f..7590557 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "imagekitio-react", - "version": "4.1.0", + "version": "4.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5200,9 +5200,9 @@ } }, "imagekit-javascript": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/imagekit-javascript/-/imagekit-javascript-3.0.0.tgz", - "integrity": "sha512-39Q54v1fwRlCYnVyalfRi9UFuUq4t+vnktWUzqjBHRguOB+wLNnAEuPbNbm0NUBJAUw5He4C1k/0vbNLOvU/4g==" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/imagekit-javascript/-/imagekit-javascript-3.0.2.tgz", + "integrity": "sha512-lTlLBrb+96eDy20zz3AIZtSs4nhozoa+kRcz3Yhl/TLAvciMmKXQe2kFOWM/j8KurvG5jLeDuMI6sCp+w7y2IA==" }, "import-local": { "version": "3.1.0", diff --git a/package.json b/package.json index 92fdef8..a2acb1e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "imagekitio-react", - "version": "4.1.0", + "version": "4.2.0", "description": "React SDK for ImageKit.io which implements client-side upload and URL generation for use inside a react application.", "scripts": { "build:js": "rollup -c", @@ -80,7 +80,7 @@ "typescript": "^4.8.2" }, "dependencies": { - "imagekit-javascript": "^3.0.0", + "imagekit-javascript": "^3.0.2", "prop-types": "^15.7.2" }, "peerDependencies": { diff --git a/src/components/IKUpload/index.tsx b/src/components/IKUpload/index.tsx index e9f59f0..83b11af 100755 --- a/src/components/IKUpload/index.tsx +++ b/src/components/IKUpload/index.tsx @@ -50,6 +50,7 @@ const IKUpload = forwardRef, "customMetadata" | "transformation"> & { @@ -111,6 +113,7 @@ export type IKUploadProps = Omit, "customMetadata" | "t validateFile?: (file: File) => boolean; transformation?: TransformationType; overrideParameters?: (file: File) => OverrideValues; + checks?: string } & React.InputHTMLAttributes; export default Props; \ No newline at end of file