33# ImageKit.io Node.js SDK
44
55[ ![ 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 )
77[ ![ codecov] ( https://codecov.io/gh/imagekit-developer/imagekit-nodejs/branch/master/graph/badge.svg )] ( https://codecov.io/gh/imagekit-developer/imagekit-nodejs )
88[ ![ Try imagekit on RunKit] ( https://badge.runkitcdn.com/imagekit.svg )] ( https://npm.runkit.com/imagekit )
99[ ![ 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
4545```
4646npm install imagekit --save
4747# or
48+ pnpm install imagekit --save
49+ # or
50+ bun install imagekit // if you are using [Bun](https://bun.sh/) compiler
51+ # or
4852yarn add imagekit
4953```
5054
@@ -351,13 +355,14 @@ imagekit.upload({
351355 }
352356 ]
353357 },
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
355360}, function (error , result ) {
356361 if (error) console .log (error);
357362 else console .log (result);
358363});
359364
360- // Using Promises
365+ // Using Promises
361366
362367imagekit .upload ({
363368 file : < url| base_64| binary> , // required
@@ -411,7 +416,7 @@ imagekit.listFiles({
411416});
412417
413418
414- // Using Promises
419+ // Using Promises
415420
416421imagekit .listFiles ({
417422 skip : 10 ,
@@ -436,7 +441,7 @@ imagekit.getFileDetails("file_id", function(error, result) {
436441});
437442
438443
439- // Using Promises
444+ // Using Promises
440445
441446imagekit .getFileDetails (" file_id" )
442447}).then (response => {
@@ -459,7 +464,7 @@ imagekit.getFileVersions("file_id", function(error, result) {
459464});
460465
461466
462- // Using Promises
467+ // Using Promises
463468
464469imagekit .getFileVersions (" file_id" )
465470}).then (response => {
@@ -485,7 +490,7 @@ imagekit.getFileVersionDetails({
485490});
486491
487492
488- // Using Promises
493+ // Using Promises
489494
490495imagekit .getFileVersionDetails ({
491496 fileId: " file_id" ,
@@ -502,10 +507,12 @@ imagekit.getFileVersionDetails({
502507
503508Update 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.
504509
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+
505512``` js
506513// Using Callback Function
507514
508- imagekit .updateFileDetails (" file_id" , {
515+ imagekit .updateFileDetails (" file_id" , {
509516 tags : [' image_tag' ],
510517 customCoordinates : " 10,10,100,100" ,
511518 extensions: [
@@ -521,18 +528,13 @@ imagekit.updateFileDetails("file_id", {
521528});
522529
523530
524- // Using Promises
531+ // Using Promises
525532
526533imagekit .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+ }
536538}).then (response => {
537539 console .log (response);
538540}).catch (error => {
@@ -616,7 +618,7 @@ imagekit.deleteFile("file_id", function(error, result) {
616618});
617619
618620
619- // Using Promises
621+ // Using Promises
620622
621623imagekit .deleteFile (" file_id" ).then (response => {
622624 console .log (response);
@@ -641,7 +643,7 @@ imagekit.deleteFileVersion({
641643});
642644
643645
644- // Using Promises
646+ // Using Promises
645647
646648imagekit .deleteFile ({
647649 fileId: " file_id" ,
@@ -666,7 +668,7 @@ imagekit.bulkDeleteFiles(["file_id_1", "file_id_2"], function(error, result) {
666668});
667669
668670
669- // Using Promises
671+ // Using Promises
670672
671673imagekit .bulkDeleteFiles ([" file_id_1" , " file_id_2" ]).then (response => {
672674 console .log (response);
@@ -925,7 +927,7 @@ imagekit.purgeCache("full_url", function(error, result) {
925927});
926928
927929
928- // Using Promises
930+ // Using Promises
929931
930932imagekit .purgeCache (" full_url" ).then (response => {
931933 console .log (response);
@@ -947,7 +949,7 @@ imagekit.getPurgeCacheStatus("cache_request_id", function(error, result) {
947949});
948950
949951
950- // Using Promises
952+ // Using Promises
951953
952954imagekit .getPurgeCacheStatus (" cache_request_id" ).then (response => {
953955 console .log (response);
@@ -968,7 +970,7 @@ imagekit.getFileMetadata("file_id", function(error, result) {
968970});
969971
970972
971- // Using Promises
973+ // Using Promises
972974imagekit .getFileMetadata (" file_id" )
973975}).then (response => {
974976 console .log (response);
@@ -987,7 +989,7 @@ imagekit.getFileMetadata("https://ik.imagekit.io/your_imagekit_id/sample.jpg", f
987989});
988990
989991
990- // Using Promises
992+ // Using Promises
991993imagekit .getFileMetadata (" https://ik.imagekit.io/your_imagekit_id/sample.jpg" )
992994}).then (response => {
993995 console .log (response);
@@ -1012,15 +1014,15 @@ imagekit.createCustomMetadataField(
10121014 minValue: 1000 ,
10131015 maxValue: 3000
10141016 }
1015- },
1017+ },
10161018 function (error , result ) {
10171019 if (error) console .log (error);
10181020 else console .log (result);
10191021 }
10201022);
10211023
10221024
1023- // Using Promises
1025+ // Using Promises
10241026
10251027imagekit .createCustomMetadataField (
10261028 {
@@ -1049,15 +1051,15 @@ Get the list of all custom metadata fields as per the [API documentation here](h
10491051imagekit .getCustomMetadataFields (
10501052 {
10511053 includeDeleted: false // optional
1052- },
1054+ },
10531055 function (error , result ) {
10541056 if (error) console .log (error);
10551057 else console .log (result);
10561058 }
10571059);
10581060
10591061
1060- // Using Promises
1062+ // Using Promises
10611063
10621064imagekit .getCustomMetadataFields (
10631065 {
@@ -1084,15 +1086,15 @@ imagekit.updateCustomMetadataField(
10841086 minValue: 500 ,
10851087 maxValue: 2500
10861088 }
1087- },
1089+ },
10881090 function (error , result ) {
10891091 if (error) console .log (error);
10901092 else console .log (result);
10911093 }
10921094);
10931095
10941096
1095- // Using Promises
1097+ // Using Promises
10961098
10971099imagekit .updateCustomMetadataField (
10981100 " field_id" ,
@@ -1101,7 +1103,7 @@ imagekit.updateCustomMetadataField(
11011103 minValue: 500 ,
11021104 maxValue: 2500
11031105 }
1104- },
1106+ },
11051107).then (response => {
11061108 console .log (response);
11071109}).catch (error => {
@@ -1125,7 +1127,7 @@ imagekit.deleteCustomMetadataField(
11251127);
11261128
11271129
1128- // Using Promises
1130+ // Using Promises
11291131
11301132imagekit .deleteCustomMetadataField (
11311133 " field_id"
0 commit comments