3
3
# ImageKit.io Node.js SDK
4
4
5
5
[ ![ Node CI] ( https://github.com/imagekit-developer/imagekit-nodejs/workflows/Node%20CI/badge.svg )] ( https://github.com/imagekit-developer/imagekit-nodejs/ )
6
- [ ![ npm version] ( https://img.shields.io/npm/v/imagekit )] ( https://www.npmjs.com/package/imagekit )
6
+ [ ![ npm version] ( https://img.shields.io/npm/v/imagekit )] ( https://www.npmjs.com/package/imagekit )
7
7
[ ![ codecov] ( https://codecov.io/gh/imagekit-developer/imagekit-nodejs/branch/master/graph/badge.svg )] ( https://codecov.io/gh/imagekit-developer/imagekit-nodejs )
8
8
[ ![ Try imagekit on RunKit] ( https://badge.runkitcdn.com/imagekit.svg )] ( https://npm.runkit.com/imagekit )
9
9
[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
@@ -45,6 +45,10 @@ Use the following command to download this module. Use the optional `--save` par
45
45
```
46
46
npm install imagekit --save
47
47
# or
48
+ pnpm install imagekit --save
49
+ # or
50
+ bun install imagekit // if you are using [Bun](https://bun.sh/) compiler
51
+ # or
48
52
yarn add imagekit
49
53
```
50
54
@@ -351,13 +355,14 @@ imagekit.upload({
351
355
}
352
356
]
353
357
},
354
- checks= {` "file.size" < "1mb"` } // To run server side checks before uploading files. Notice the quotes around file.size and 1mb.
358
+ checks: {` "file.size" < "1mb"` }, // To run server side checks before uploading files. Notice the quotes around file.size and 1mb.
359
+ isPublished: true
355
360
}, function (error , result ) {
356
361
if (error) console .log (error);
357
362
else console .log (result);
358
363
});
359
364
360
- // Using Promises
365
+ // Using Promises
361
366
362
367
imagekit .upload ({
363
368
file : < url| base_64| binary> , // required
@@ -411,7 +416,7 @@ imagekit.listFiles({
411
416
});
412
417
413
418
414
- // Using Promises
419
+ // Using Promises
415
420
416
421
imagekit .listFiles ({
417
422
skip : 10 ,
@@ -436,7 +441,7 @@ imagekit.getFileDetails("file_id", function(error, result) {
436
441
});
437
442
438
443
439
- // Using Promises
444
+ // Using Promises
440
445
441
446
imagekit .getFileDetails (" file_id" )
442
447
}).then (response => {
@@ -459,7 +464,7 @@ imagekit.getFileVersions("file_id", function(error, result) {
459
464
});
460
465
461
466
462
- // Using Promises
467
+ // Using Promises
463
468
464
469
imagekit .getFileVersions (" file_id" )
465
470
}).then (response => {
@@ -485,7 +490,7 @@ imagekit.getFileVersionDetails({
485
490
});
486
491
487
492
488
- // Using Promises
493
+ // Using Promises
489
494
490
495
imagekit .getFileVersionDetails ({
491
496
fileId: " file_id" ,
@@ -502,10 +507,12 @@ imagekit.getFileVersionDetails({
502
507
503
508
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 the second argument is an object with the parameters to be updated.
504
509
510
+ Note: If ` publish ` is included in the update options, no other parameters are allowed. If any are present, an error will be returned: ` Your request cannot contain any other parameters when publish is present ` .
511
+
505
512
``` js
506
513
// Using Callback Function
507
514
508
- imagekit .updateFileDetails (" file_id" , {
515
+ imagekit .updateFileDetails (" file_id" , {
509
516
tags : [' image_tag' ],
510
517
customCoordinates : " 10,10,100,100" ,
511
518
extensions: [
@@ -521,18 +528,13 @@ imagekit.updateFileDetails("file_id", {
521
528
});
522
529
523
530
524
- // Using Promises
531
+ // Using Promises
525
532
526
533
imagekit .updateFileDetails (" file_id" , {
527
- tags : [' image_tag' ],
528
- customCoordinates : " 10,10,100,100" ,
529
- extensions: [
530
- {
531
- name: " google-auto-tagging" ,
532
- maxTags: 5 ,
533
- minConfidence: 95
534
- }
535
- ]
534
+ publish: {
535
+ isPublished: true ,
536
+ includeFileVersions: true
537
+ }
536
538
}).then (response => {
537
539
console .log (response);
538
540
}).catch (error => {
@@ -616,7 +618,7 @@ imagekit.deleteFile("file_id", function(error, result) {
616
618
});
617
619
618
620
619
- // Using Promises
621
+ // Using Promises
620
622
621
623
imagekit .deleteFile (" file_id" ).then (response => {
622
624
console .log (response);
@@ -641,7 +643,7 @@ imagekit.deleteFileVersion({
641
643
});
642
644
643
645
644
- // Using Promises
646
+ // Using Promises
645
647
646
648
imagekit .deleteFile ({
647
649
fileId: " file_id" ,
@@ -666,7 +668,7 @@ imagekit.bulkDeleteFiles(["file_id_1", "file_id_2"], function(error, result) {
666
668
});
667
669
668
670
669
- // Using Promises
671
+ // Using Promises
670
672
671
673
imagekit .bulkDeleteFiles ([" file_id_1" , " file_id_2" ]).then (response => {
672
674
console .log (response);
@@ -925,7 +927,7 @@ imagekit.purgeCache("full_url", function(error, result) {
925
927
});
926
928
927
929
928
- // Using Promises
930
+ // Using Promises
929
931
930
932
imagekit .purgeCache (" full_url" ).then (response => {
931
933
console .log (response);
@@ -947,7 +949,7 @@ imagekit.getPurgeCacheStatus("cache_request_id", function(error, result) {
947
949
});
948
950
949
951
950
- // Using Promises
952
+ // Using Promises
951
953
952
954
imagekit .getPurgeCacheStatus (" cache_request_id" ).then (response => {
953
955
console .log (response);
@@ -968,7 +970,7 @@ imagekit.getFileMetadata("file_id", function(error, result) {
968
970
});
969
971
970
972
971
- // Using Promises
973
+ // Using Promises
972
974
imagekit .getFileMetadata (" file_id" )
973
975
}).then (response => {
974
976
console .log (response);
@@ -987,7 +989,7 @@ imagekit.getFileMetadata("https://ik.imagekit.io/your_imagekit_id/sample.jpg", f
987
989
});
988
990
989
991
990
- // Using Promises
992
+ // Using Promises
991
993
imagekit .getFileMetadata (" https://ik.imagekit.io/your_imagekit_id/sample.jpg" )
992
994
}).then (response => {
993
995
console .log (response);
@@ -1012,15 +1014,15 @@ imagekit.createCustomMetadataField(
1012
1014
minValue: 1000 ,
1013
1015
maxValue: 3000
1014
1016
}
1015
- },
1017
+ },
1016
1018
function (error , result ) {
1017
1019
if (error) console .log (error);
1018
1020
else console .log (result);
1019
1021
}
1020
1022
);
1021
1023
1022
1024
1023
- // Using Promises
1025
+ // Using Promises
1024
1026
1025
1027
imagekit .createCustomMetadataField (
1026
1028
{
@@ -1049,15 +1051,15 @@ Get the list of all custom metadata fields as per the [API documentation here](h
1049
1051
imagekit .getCustomMetadataFields (
1050
1052
{
1051
1053
includeDeleted: false // optional
1052
- },
1054
+ },
1053
1055
function (error , result ) {
1054
1056
if (error) console .log (error);
1055
1057
else console .log (result);
1056
1058
}
1057
1059
);
1058
1060
1059
1061
1060
- // Using Promises
1062
+ // Using Promises
1061
1063
1062
1064
imagekit .getCustomMetadataFields (
1063
1065
{
@@ -1084,15 +1086,15 @@ imagekit.updateCustomMetadataField(
1084
1086
minValue: 500 ,
1085
1087
maxValue: 2500
1086
1088
}
1087
- },
1089
+ },
1088
1090
function (error , result ) {
1089
1091
if (error) console .log (error);
1090
1092
else console .log (result);
1091
1093
}
1092
1094
);
1093
1095
1094
1096
1095
- // Using Promises
1097
+ // Using Promises
1096
1098
1097
1099
imagekit .updateCustomMetadataField (
1098
1100
" field_id" ,
@@ -1101,7 +1103,7 @@ imagekit.updateCustomMetadataField(
1101
1103
minValue: 500 ,
1102
1104
maxValue: 2500
1103
1105
}
1104
- },
1106
+ },
1105
1107
).then (response => {
1106
1108
console .log (response);
1107
1109
}).catch (error => {
@@ -1125,7 +1127,7 @@ imagekit.deleteCustomMetadataField(
1125
1127
);
1126
1128
1127
1129
1128
- // Using Promises
1130
+ // Using Promises
1129
1131
1130
1132
imagekit .deleteCustomMetadataField (
1131
1133
" field_id"
0 commit comments