Copy an object

Last Updated: May 16, 2017

In certain situations, you simply need to copy an object to another bucket, without modifying its content. The standard process is to first download the object, and then upload the object to the new bucket. However, because data is identical for both objects, network bandwidth is wasted. To overcome this issue, OSS provides the CopyObject function to copy objects directly within the OSS without the need to transmit large volumes of data between the user and the OSS.

Additionally, because OSS does not support renaming, it is recommended that the OSS CopyObject interface is called for renaming an object. This means you can first copy the original data to an object, apply a new name, and then delete the original file. To only modify an object’s Object Meta (object metadata), you can also call the CopyObject interface and set the source address and destination address to the same value. In this way, the OSS will only update the Object Meta. For more details about Object Meta, refer to Object Meta.

Before copying an object, note the following precautions:

  • You must have permissions to operate the source object. Otherwise the operation will fail.
  • Data cannot be copied across regions. For example, an object in a Hangzhou bucket may not be copied to a Qingdao bucket.
  • Objects up to 1 GB are supported.
  • Appended objects cannot be copied.

Reference

Copy large objects

You need to take different steps to copy a large object. The OSS supports the function of copying large files similar to Multipart upload.

The only difference is that the process UploadPart is replaced by the process UploadPartCopy. The syntax of UploadPartCopy is similar to that of UploadPart. However, instead of being directly uploaded from the HTTP request, data is retrieved from the source object.

Reference:

Thank you! We've received your feedback.