Rename and Move Operations on an ObjectAdmin Scope

Note: Ensure you have installed the required package to use this SDK method.

Parameters Used

Parameter Name Data Type Definition
key String The original name of the object that you need to rename or move.
destination String The new name of the object, containing the complete path information.

Notes:
  • 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:

    • source_object value will be ‘pictures/puppy/kitten.png
    • dest_object value will be ‘pictures/kitten/kitten.png’

The renameObject() SDK method can be used for both rename and move operations. The bucket reference used in the following code snippet is the component instance.

Rename an Object

Notes:
  • You cannot rename objects in a bucket that has Versioning enabled.

  • The following characters including space are not supported when you create a path or an object: double quote, both angular brackets, hashtag, backward slash and pipe symbol.

copy
const res = await bucket.renameObject("sam/out/sample.txt", "sam/out/update_sample.txt");
console.log(res);

Move an Object

Note: You cannot perform move operations in a bucket that has Versioning enabled.
copy
const moveRes = await bucket.renameObject("sam/out/sample.txt", "out/sample.txt");
console.log(moveRes);

Example of Expected Response

copy
{
  "current_key": "sam/out/sample.txt",
  "message": "Rename successful",
  "rename_to": "sam/out/update_sample.txt"
}

Last Updated 2026-07-02 14:51:41 +0530 IST