Skip to content

Commit 2ea48ef

Browse files
committed
add file copy method
1 parent 9ce7a56 commit 2ea48ef

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/imagekitio/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ def bulk_ai_tags_remove(file_ids = [], ai_tags = [])
116116
@file.batch_ai_tags_remove(file_ids, ai_tags)
117117
end
118118

119+
def copy_file(source_file_path, destination_path)
120+
@file.copy(source_file_path, destination_path)
121+
end
122+
119123
def phash_distance(first, second)
120124
# Get hamming distance between two phash(image hash) to check
121125
# similarity between images

lib/imagekitio/file.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ def batch_ai_tags_remove(file_ids, ai_tags)
142142
@req_obj.request('post', url, @req_obj.create_headers, payload)
143143
end
144144

145+
def copy(source_file_path, destination_path)
146+
url = "#{constants.BASE_URL}/copy"
147+
payload = { 'sourceFilePath': source_file_path, 'destinationPath': destination_path }
148+
@req_obj.request('post', url, @req_obj.create_headers, payload)
149+
end
150+
145151
def validate_upload_options(options)
146152

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

0 commit comments

Comments
 (0)