You can copy objects from one bucket to another bucket without modifying the object content.
|ossbrowser||Easy-to-operate graphical tool
Notice You can only use ossbrowser to copy objects smaller than 5 GB.
|ossutil||High-performance command-line tool|
|Java SDK||SDK demos for various programming languages|
- Back up an object
If you want to save a backup of an object, you can call the CopyObject operation to copy the object to another bucket within the same region.
- Rename an object
OSS does not allow you to directly rename an object. If you want to rename an object, you can call the CopyObject operation to copy the original object, rename it, save the renamed object, and delete the original object.
- Modify the metadata of an object
If you only need to modify the metadata of an object, you can also call the CopyObject operation to copy the object, save it in the same location, and modify the metadata of the object. This way, OSS only updates the metadata of the object. For more information about object metadata, see Manage object metadata.
Before you copy objects, note that:
- You must have the read permissions on the source object and the read and write permissions on the destination bucket. Otherwise, the copy operation may fail.
- You are not allowed to copy data across regions. For example, you are not allowed to copy an object from a bucket in the China (Hangzhou) region to a bucket in the China (Qingdao) region.
- You are not allowed to copy objects created by using append upload.
- By default, when you copy an object, the existing object with the same object name will be overwritten. You can use the following methods to protect your objects from being unexpectedly overwritten:
- Enable versioning
If versioning is enabled, deleted or overwritten objects are saved as previous versions. You can recover the previous versions at any time. For more information, see Versioning.
- Include a parameter in the copy request header
Include the x-oss-forbid-overwrite parameter in the copy request header, and set its value to true. This way, when you copy an object whose object name is the same as that of an existing object, the object cannot be copied. OSS returns the
FileAlreadyExistserror. For more information, see CopyObject.
If this parameter is not included in the request header or the value of this parameter is false, the object with the same object name is overwritten.
- Enable versioning