Copying an Object
This section describes how to copy an object in OBS. You can copy an object of up to 5 GB by an operation. To copy an object of larger than 5 GB, you must use multipart upload APIs. Specifically, the CopyObject operation allows you to:
- Create a copy for an object.
- Rename an object by creating a copy for it and deleting the source object.
- Change the metadata of an object. Every object has metadata which is a field-value pair. When you upload an object, you can set its metadata. After the object is uploaded, you cannot modify its metadata. The only way to modify object metadata is to create an object copy and set metadata. In the copy operation, set the target object to the same as the source object.
Each object contains metadata, including system metadata and user-defined metadata. Users can control some system metadata. In the event of copying an object, user-controlled system metadata and user-defined metadata are copied too. OBS resets the metadata controlled by the system. For example, when you copy an object, the OBS resets the creation date of the copied object. In the copy request, you do not need to set such value.
When copying an object, you may want to update some metadata. For example, when the source object is configured to use standard storage, you may want to configure the object copy to using low-redundancy storage. You may also want to modify some user-defined metadata of the source object. If you want to modify metadata, even only one metadata, that can be configured by users (defined by users or the system), specify all the metadata that can be configured by users on the source object in the request.
When versioning is disabled for a bucket, if you copy object a as object b and an object named object b already exists, the new object b will overwrite the old object b. After the copying is executed successfully, only new object b can be downloaded because old object b has been deleted. Therefore, before copying an object, ensure that there is no object with the same name as the object copy to prevent data from being deleted mistakenly. During the copying, object a has no changes. You cannot determine whether a request is executed successfully only using status_code in the header returned by HTTP. If 200 in status_code is returned, the server has received the request and starts to process the request. The body in the response shows whether the request is executed successfully. The request is executed successfully only when the body contains Etag. Otherwise, the request fails to be executed.
For more information, see section Copying Objects.
Last Article: Uploading an Object Using the POST Method
Next Article: Obtaining an Object
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.