Skip to content

Commit 5259c99

Browse files
authored
Merge pull request #115 from imagekit-developer/IK-1499
added checks parameter
2 parents 0048fb9 + b86fefd commit 5259c99

File tree

8 files changed

+1795
-1782
lines changed

8 files changed

+1795
-1782
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ To use the SDK, you need to provide it with a few configuration parameters. The
209209
}
210210
]
211211
}"
212+
[checks]="'\'request.folder\' : \'sample-folder/\''" // To run server side checks before uploading files. Notice the quotes around request.folder and sample-folder.
212213
></ik-upload>
213214
```
214215

@@ -562,6 +563,7 @@ The SDK provides a component to upload files to the [ImageKit Media Library](htt
562563
| urlEndpoint | String | Optional. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/ |
563564
| publicKey | String | Optional |
564565
| authenticator | ()=>Promise<{signature:string,token:string,expiry:number}> | Optional |
566+
| 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.` |
565567

566568
Note: `urlEndpoint` and `publicKey` must be present in the attribute for them to take effect. Otherwise, the SDK will fall back to the values specified in `app.module.ts`.
567569

sdk/package-lock.json

Lines changed: 1779 additions & 1777 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagekitio-angular",
3-
"version": "5.0.0",
3+
"version": "5.1.0",
44
"license": "MIT",
55
"scripts": {
66
"ng": "ng",
@@ -26,7 +26,7 @@
2626
"@angular/platform-browser": "~12.2.0",
2727
"@angular/platform-browser-dynamic": "~12.2.0",
2828
"@angular/router": "~12.2.0",
29-
"imagekit-javascript": "^3.0.0",
29+
"imagekit-javascript": "^3.0.2",
3030
"rxjs": "~6.6.0",
3131
"tslib": "^2.3.0",
3232
"zone.js": "~0.11.4"

sdk/projects/imagekitio-angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "imagekitio-angular",
3-
"version": "5.0.0",
3+
"version": "5.1.0",
44
"peerDependencies": {
55
"@angular/common": ">=12.2.0",
66
"@angular/core": ">=12.2.0",
7-
"imagekit-javascript": "^3.0.0"
7+
"imagekit-javascript": "^3.0.2"
88
},
99
"dependencies": {
1010
"tslib": "^2.3.0"

sdk/projects/imagekitio-angular/src/lib/ik-upload/ik-upload.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class IkUploadComponent implements AfterViewInit {
3737
@Input('onUploadStart') onUploadStart: (e: HTMLInputEvent) => void;
3838
@Input('onUploadProgress') onUploadProgress: (e: ProgressEvent) => void;
3939
@Input('transformation') transformation: Object; //optional
40+
@Input('checks') checks: string; //optional
4041
fileToUpload: File = null;
4142
xhr: XMLHttpRequest;
4243

@@ -76,6 +77,7 @@ export class IkUploadComponent implements AfterViewInit {
7677
onError: this.onError,
7778
onSuccess: this.onSuccess,
7879
transformation: this.transformation,
80+
checks: this.checks
7981
}
8082

8183
// Custom validation
@@ -250,6 +252,11 @@ export class IkUploadComponent implements AfterViewInit {
250252
if (options.transformation !== undefined) {
251253
Object.assign(params, { transformation: options.transformation });
252254
}
255+
256+
if (options.checks !== undefined) {
257+
Object.assign(params, { checks: options.checks });
258+
}
259+
253260
return params;
254261
}
255262
}

sdk/projects/imagekitio-angular/src/lib/imagekitio-angular.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@angular/core';
22
import ImageKit from 'imagekit-javascript';
3-
const SDK_VERSION = '5.0.0';
3+
const SDK_VERSION = '5.1.0';
44
export interface Lqip {
55
readonly active: boolean;
66
readonly quality: number;

sdk/projects/imagekitio-angular/src/lib/utility/ik-type-def-collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export interface IkUploadComponentOptions {
5555
validateFile?: Function;
5656
xhr?: XMLHttpRequest;
5757
transformation?: Object;
58+
checks?: string;
5859
}
5960

6061
export interface AuthResponse {

sdk/src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ <h1>Hi! This is an ImageKit Angular SDK Demo!</h1>
9292
[onUploadStart]="onUploadStartFunction"
9393
[onUploadProgress]="onUploadProgressFunction"
9494
[authenticator]="authenticator"
95+
[checks]="'\'request.folder\' : \'sample-folder/\''"
9596
class="file-upload-ik">
9697
</ik-upload>
9798
<button (click)="onAbortFunction()">Abort</button>

0 commit comments

Comments
 (0)