Renaming an Object Storage Object
Rename an object in an Object Storage bucket.
For information about object naming, see Object Names.
Use the oci os object rename command and required parameters to rename an object in a bucket:
oci os object rename --bucket-name bucket_name --name object_original_name --new-name object_new_name [OPTIONS]
For example:
oci os object rename --bucket-name MyBucket --name MyFile.txt --new-name MyRenamedFile.txt { "etag": "3504606b-8412-4b5d-924a-aeaeacf1df1e" }
Renaming an Object having a Specific Entity Tag
To make the rename operation dependent on the object having a specific entity tag, use the
--src-obj-if-match-e-tag
option.For example:
oci os object rename --bucket-name MyBucket --name MyFile.txt --new-name MyRenamedFile.txt --src-obj-if-match-e-tag 6672BECB67CCFFBCE0530292F20ZBACE
Overwriting an Object
For rename operations where you intend to overwrite one object in a bucket with another, you can make the renaming dependent on having a specific entity tag. To do so, use the
--new-obj-if-match-e-tag
option.For example:
oci os object rename --bucket-name MyBucket --name MyFile.txt --new-name MyRenamedFile.txt --new-obj-if-match-e-tag 6672BECB67CCFFBCE0530292F20ZBACE
Preventing Overwriting an Object
When renaming an object, you can prevent the system from overwriting another object in the same bucket by using the
--new-obj-if-none-match-e-tag *
option. This option prevents the renaming operation from completing if an object exists with the--new-name
value specified and the same entity tag of the source object.For example:
oci os object rename --bucket-name MyBucket --name MyFile.txt --new-name MyRenamedFile.txt --new-obj-if-none-match-e-tag *
For a complete list of parameters and values for CLI commands, see the CLI Command Reference.
Run the RenameObject operation to rename an object in a bucket.
Object Storage prepends the Object Storage namespace string and bucket name to the object name when constructing a URL for use with the API:
/n/object_storage_namespace/b/bucket/o/object_name
The object name is everything after the
/o/
, which could include hierarchy levels and prefix strings.