@@ -161,5 +161,209 @@ module.exports.bulkAddTags = function(fileIdArray, tags, defaultOptions, callbac
161161 json : data
162162 }
163163
164+ request ( requestOptions , defaultOptions , callback ) ;
165+ } ;
166+
167+ /*
168+ Remove tags in bulk
169+ */
170+ module . exports . bulkRemoveTags = function ( fileIdArray , tags , defaultOptions , callback ) {
171+
172+ if ( ! Array . isArray ( fileIdArray )
173+ || fileIdArray . length === 0
174+ || fileIdArray . filter ( fileId => typeof ( fileId ) !== 'string' ) . length > 0 ) {
175+ respond ( true , errorMessages . INVALID_FILEIDS_VALUE , callback ) ;
176+ return ;
177+ }
178+
179+ if ( ! Array . isArray ( tags )
180+ || tags . length === 0
181+ || tags . filter ( tag => typeof ( tag ) !== 'string' ) . length > 0 ) {
182+ respond ( true , errorMessages . BULK_ADD_TAGS_INVALID , callback ) ;
183+ return ;
184+ }
185+
186+ const data = {
187+ fileIds : fileIdArray ,
188+ tags : tags
189+ }
190+
191+ const requestOptions = {
192+ url : "https://api.imagekit.io/v1/files/removeTags" ,
193+ method : "POST" ,
194+ json : data
195+ }
196+
197+ request ( requestOptions , defaultOptions , callback ) ;
198+ } ;
199+
200+ /*
201+ Copy file
202+ */
203+ module . exports . copyFile = function ( sourceFilePath , destinationPath , defaultOptions , callback ) {
204+
205+ if ( sourceFilePath . length === 0 || typeof ( sourceFilePath ) !== 'string'
206+ || destinationPath . length === 0 || typeof ( destinationPath ) !== 'string' ) {
207+ respond ( true , errorMessages . INVALID_DIRECTORY_PATH , callback ) ;
208+ return ;
209+ }
210+
211+ const data = {
212+ sourceFilePath : sourceFilePath ,
213+ destinationPath : destinationPath
214+ }
215+
216+ const requestOptions = {
217+ url : "https://api.imagekit.io/v1/files/copy" ,
218+ method : "POST" ,
219+ json : data
220+ }
221+
222+ request ( requestOptions , defaultOptions , callback ) ;
223+ } ;
224+
225+ /*
226+ Move file
227+ */
228+ module . exports . moveFile = function ( sourceFilePath , destinationPath , defaultOptions , callback ) {
229+
230+ if ( sourceFilePath . length === 0 || typeof ( sourceFilePath ) !== 'string'
231+ || destinationPath . length === 0 || typeof ( destinationPath ) !== 'string' ) {
232+ respond ( true , errorMessages . INVALID_DIRECTORY_PATH , callback ) ;
233+ return ;
234+ }
235+
236+ const data = {
237+ sourceFilePath : sourceFilePath ,
238+ destinationPath : destinationPath
239+ }
240+
241+ const requestOptions = {
242+ url : "https://api.imagekit.io/v1/files/move" ,
243+ method : "POST" ,
244+ json : data
245+ }
246+
247+ request ( requestOptions , defaultOptions , callback ) ;
248+ } ;
249+
250+ /*
251+ Copy Folder
252+ */
253+ module . exports . copyFolder = function ( sourceFolderPath , destinationPath , defaultOptions , callback ) {
254+
255+ if ( sourceFolderPath . length === 0 || typeof ( sourceFolderPath ) !== 'string'
256+ || destinationPath . length === 0 || typeof ( destinationPath ) !== 'string' ) {
257+ respond ( true , errorMessages . INVALID_DIRECTORY_PATH , callback ) ;
258+ return ;
259+ }
260+
261+ const data = {
262+ sourceFolderPath : sourceFolderPath ,
263+ destinationPath : destinationPath
264+ }
265+
266+ const requestOptions = {
267+ url : "https://api.imagekit.io/v1/bulkJobs/copyFolder" ,
268+ method : "POST" ,
269+ json : data
270+ }
271+
272+ request ( requestOptions , defaultOptions , callback ) ;
273+ } ;
274+
275+ /*
276+ Move Folder
277+ */
278+ module . exports . moveFolder = function ( sourceFolderPath , destinationPath , defaultOptions , callback ) {
279+
280+ if ( sourceFolderPath . length === 0 || typeof ( sourceFolderPath ) !== 'string'
281+ || destinationPath . length === 0 || typeof ( destinationPath ) !== 'string' ) {
282+ respond ( true , errorMessages . INVALID_DIRECTORY_PATH , callback ) ;
283+ return ;
284+ }
285+
286+ const data = {
287+ sourceFolderPath : sourceFolderPath ,
288+ destinationPath : destinationPath
289+ }
290+
291+ const requestOptions = {
292+ url : "https://api.imagekit.io/v1/bulkJobs/moveFolder" ,
293+ method : "POST" ,
294+ json : data
295+ }
296+
297+ request ( requestOptions , defaultOptions , callback ) ;
298+ } ;
299+
300+ /*
301+ Create folder
302+ */
303+ module . exports . createFolder = function ( folderName , parentFolderPath , defaultOptions , callback ) {
304+
305+ if ( folderName . length === 0 || typeof ( folderName ) !== 'string' ) {
306+ respond ( true , errorMessages . INVALID_FOLDER_NAME , callback ) ;
307+ return ;
308+ }
309+
310+ if ( parentFolderPath . length === 0 || typeof ( parentFolderPath ) !== 'string' ) {
311+ respond ( true , errorMessages . INVALID_DIRECTORY_PATH , callback ) ;
312+ return ;
313+ }
314+
315+ const data = {
316+ folderName : folderName ,
317+ parentFolderPath : parentFolderPath
318+ }
319+
320+ const requestOptions = {
321+ url : "https://api.imagekit.io/v1/folder/" ,
322+ method : "POST" ,
323+ json : data
324+ }
325+
326+ request ( requestOptions , defaultOptions , callback ) ;
327+ } ;
328+
329+ /*
330+ Delete folder
331+ */
332+ module . exports . deleteFolder = function ( folderPath , defaultOptions , callback ) {
333+
334+ if ( folderPath . length === 0 || typeof ( folderPath ) !== 'string' ) {
335+ respond ( true , errorMessages . INVALID_DIRECTORY_PATH , callback ) ;
336+ return ;
337+ }
338+
339+ const data = {
340+ folderPath : folderPath
341+ }
342+
343+ const requestOptions = {
344+ url : "https://api.imagekit.io/v1/folder" ,
345+ method : "DELETE" ,
346+ json : data
347+ }
348+
349+ request ( requestOptions , defaultOptions , callback ) ;
350+ } ;
351+
352+ /*
353+ Bulk job status
354+ */
355+ module . exports . getBulkJobStatus = function ( jobId , defaultOptions ) {
356+
357+ if ( ! jobId ) {
358+ respond ( true , errorMessages . JOB_ID_MISSING , callback ) ;
359+ return ;
360+ }
361+
362+ const requestOptions = {
363+ url : "https://api.imagekit.io/v1/bulkJobs/" + jobId ,
364+ method : "GET" ,
365+ json : true
366+ } ;
367+
164368 request ( requestOptions , defaultOptions , callback ) ;
165369} ;
0 commit comments