Copying Objects
Scenarios
You can copy objects in OBS. An object of up to 5 GB can be copied by each operation. To copy an object larger than 5 GB, use the multipart upload API. Specifically, this copy operation allows you to:
- Create a copy for an object.
- Rename an object by creating a copy for it and deleting the source object.
- Edit object metadata. Each object has metadata, which is a set of name-value pairs. You can set object metadata when uploading the object. After you upload the object, you can modify its metadata using an API. For details, see Modifying Object Metadata. You can also create an object copy and set the metadata. In the copy operation, set the target object to be the same as the source object.
Each object contains metadata, including system metadata and user-defined metadata. You can control some system metadata. When you copy 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, if the source object is configured to be in Standard storage, you may want to change the storage class of the object copy to Infrequent Access. You may also want to modify some user-defined metadata of the source object. If you want to modify metadata, even only one piece of 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.
- OBS allows you to replicate the service data stored in OBS to a specified region, but Huawei Cloud does not detect the stored data and is not responsible for the legal compliance of your use of OBS. If your replication involves cross-border transfer, ensure that your use complies with relevant laws and regulations.
- When versioning is disabled for a bucket, if you make a copy of objecta and save it as objectb, and an object named objectb already exists before this copy, the new objectb will overwrite the existing one. After the copy succeeds, only new objectb can be downloaded because old objectb has been deleted. Therefore, before copying an object, make sure that there is no object with the same name as the object copy to prevent data from being deleted mistakenly. Source object objecta does not change during the copying.
- 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.
How to Use
You can use APIs, SDKs, OBS Browser+, or obsutil to copy objects.
Tool |
Reference |
---|---|
SDKs |
OBS supports software development kits (SDKs) in multiple languages. For details, see the corresponding developer guide on the SDK Overview page. |
API |
|
OBS Browser+ |
|
obsutil |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.