Rename and Move Operations on an Object
To rename and to move an object, we will be using the same renameObject() SDK method.
Rename an Object
Using the renameObject() SDK method you can rename objects present in a bucket.
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
key | String | The original name of the object that you need to rename |
destination | String | The new name that you rename the object with |
Ensure the following packages are imported:
copyimport org.json.simple.JSONObject;
copyJSONObject res = bucket.renameObject("sam/out/sample.txt", "sam/out/update_sample.txt"); System.out.println(res);
Move an Object
Using the renameObject() SDK method, we can move the object from one path to another within a bucket.
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
key | String | The complete name and path of the object that you are required to move. |
destination | String | The complete name and new path of the object. |
-
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 move the file to pictures/kitten path, then:
key value will be ‘pictures/puppy/kitten.png’
destination value will be ‘pictures/kitten/kitten.png’
Ensure the following packages are imported:
copyimport org.json.simple.JSONObject;
copyJSONObject res = bucket.renameObject("sam/out/sample.txt", "output/sample.txt"); System.out.println(res);
Last Updated 2025-05-30 16:54:59 +0530 +0530
Yes
No
Send your feedback to us