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
@@ -219,11 +219,25 @@ The `upload()` method requires at least the `file` and the `fileName` parameter
219
219
220
220
Sample usage
221
221
```
222
+
// Using Callback Function
223
+
222
224
imagekit.upload({
223
-
file : <url|base_64|binary>, //required
224
-
fileName : "my_file_name.jpg", //required
225
+
file : <url|base_64|binary>, //required
226
+
fileName : "my_file_name.jpg", //required
225
227
}, function(error, result) {
228
+
if(error) console.log(error);
229
+
else console.log(result);
230
+
});
226
231
232
+
// Using Promises
233
+
234
+
imagekit.upload({
235
+
file : <url|base_64|binary>, //required
236
+
fileName : "my_file_name.jpg", //required
237
+
}).then(response => {
238
+
console.log(response);
239
+
}).catch(error => {
240
+
console.log(error);
227
241
});
228
242
```
229
243
@@ -241,11 +255,26 @@ The SDK provides a simple interface for all the [media APIs mentioned here](http
241
255
Accepts an object specifying the parameters to be used to list and search files. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) can be passed as is with the correct values to get the results.
242
256
243
257
```
258
+
// Using Callback Function
259
+
260
+
imagekit.listFiles({
261
+
skip : 10,
262
+
limit : 10
263
+
}, function(error, result) {
264
+
if(error) console.log(error);
265
+
else console.log(result);
266
+
});
267
+
268
+
269
+
// Using Promises
270
+
244
271
imagekit.listFiles({
245
272
skip : 10,
246
273
limit : 10
247
-
}, function(err, result) {
248
-
274
+
}).then(response => {
275
+
console.log(response);
276
+
}).catch(error => {
277
+
console.log(error);
249
278
});
250
279
```
251
280
@@ -254,8 +283,21 @@ imagekit.listFiles({
254
283
Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details).
Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files).
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.
Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file). The method accepts the file ID of the file that has to be deleted.
Delete multiple file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk). The method accepts an array of file IDs of the files that have to be deleted.
Programmatically issue a cache clear request as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache). Accepts the full URL of the file for which the cache has to be cleared.
Get the purge cache request status using the request ID returned when a purge cache request gets submitted as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status)
Copy file name to clipboardExpand all lines: constants/errorMessages.js
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,4 +15,6 @@ module.exports = {
15
15
"INVALID_PHASH_VALUE": {message: "Invalid pHash value",help: "Both pHash strings must be valid hexadecimal numbers"},
16
16
"MISSING_PHASH_VALUE": {message: "Missing pHash value",help: "Please pass two pHash values"},
17
17
"UNEQUAL_STRING_LENGTH": {message: "Unequal pHash string length",help: "For distance calucation, the two pHash strings must have equal length"},
18
+
//bulk delete errors
19
+
"INVALID_FILEIDS_VALUE": {message: "Invalid value for fileIds",help: "fileIds should be an string array of fileId of the files to delete. The array should have atleast one fileId."}
0 commit comments