Skip to content

Commit 837b7fe

Browse files
committed
add copy folder method
1 parent e2a0447 commit 837b7fe

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lib/imagekitio/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ def delete_folder(folder_path)
136136
@file.delete_folder(folder_path)
137137
end
138138

139+
def copy_folder(source_folder_path, destination_path)
140+
@file.copy_folder(source_folder_path, destination_path)
141+
end
142+
139143
def phash_distance(first, second)
140144
# Get hamming distance between two phash(image hash) to check
141145
# similarity between images

lib/imagekitio/constants/url.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module URL
77
BULK_FILE_DELETE = "/batch/deleteByFileIds"
88
UPLOAD = "/upload"
99
REMOTE_METADATA_FULL_URL = "https://api.imagekit.io/v1/metadata"
10+
BULK_BASE_URL = 'https://api.imagekit.io/v1/bulkJobs'
1011
end
1112
end
1213
end

lib/imagekitio/file.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ def delete_folder(folder_path)
187187
@req_obj.request('delete', url, @req_obj.create_headers, payload)
188188
end
189189

190+
def copy_folder(source_folder_path, destination_path)
191+
if source_folder_path == '' || source_folder_path.nil? || destination_path == '' || destination_path.nil?
192+
raise ArgumentError, 'parameters required'
193+
end
194+
url = "#{constants.BULK_BASE_URL}/copyFolder"
195+
payload = { 'sourceFolderPath': source_folder_path, 'destinationPath': destination_path }
196+
@req_obj.request('post', url, @req_obj.create_headers, payload)
197+
end
198+
190199
def validate_upload_options(options)
191200

192201
# Validates upload value, checks if params are valid,

0 commit comments

Comments
 (0)