Copy Object

Using this SDK method, you can copy an object and paste it within a bucket. The Bucket reference used in the below code snippet is the component instance.

Info: To use this SDK method, you need intialize it with Admin scope. You can learn more about this requirement from this section

The key will be the object you are going to copy, and the destination, will contain the new name of the copied object. To paste the copied object in a different path, you need to provide the complete path name as dest_object.

Note:
  • You need to provide the complete object name, along with the path for both key and destination values.

  • For example, if you have file named “kitten.png” in the path pictures/puppy, and you need to copy the file to pictures/kitten path, then:

key value will be ‘pictures/puppy/kitten.png

destination value will be ‘pictures/kitten/kitten.png


    
copy
res = bucket.copy_object("sam/out/sample.txt","output/sample.txt") print(res)

Example Response

    
copy
{ "copy_to": "output/sample.txt", "object_key": "sam/out/sample.txt", "message": "Object copied successfully." }

Last Updated 2025-05-30 16:54:59 +0530 +0530