Copies data from an existing object as a part and uploads the part. Use this command when copying objects larger than 1 GB as part of a multipart upload workflow.
Usage notes
To copy an object smaller than 1 GB with a single command, use copy-object instead.
The source and destination buckets must be in the same region.
Run initiate-multipart-upload first to get an upload ID from OSS before running this command.
Permissions
By default, an Alibaba Cloud account has full permissions. RAM users and RAM roles have no permissions by default. Grant the required permissions through a RAM Policy or bucket policy.
| API | Action | Description |
|---|---|---|
| UploadPartCopy | oss:GetObject | Reads data from the source object |
oss:PutObject | Writes data to the destination object | |
oss:GetObjectVersion | Reads a specific version of the source object when versionId is specified |
Syntax
Required parameters are shown without brackets. Optional parameters are enclosed in [brackets].
ossutil api upload-part-copy
--bucket <value>
--copy-source <value>
--key <value>
--part-number <value>
--upload-id <value>
[--copy-source-if-match <value>]
[--copy-source-if-modified-since <value>]
[--copy-source-if-none-match <value>]
[--copy-source-if-unmodified-since <value>]
[--copy-source-range <value>]
[--metadata-directive <value>]
[--tagging <value>]
[--tagging-directive <value>]
[flags]Required parameters
| Parameter | Type | Description |
|---|---|---|
--bucket | string | Name of the bucket in which the source object is stored |
--copy-source | string | Address of the source object. Format: bucket/UrIEncode(key). The object name must be URL-encoded. The source and destination buckets must be in the same region. |
--key | string | Full path of the source object from which you want to copy data |
--part-number | string | Part number that identifies this part in the multipart upload |
--upload-id | string | Upload ID of the multipart upload task, obtained from initiate-multipart-upload |
Optional parameters
| Parameter | Type | Description |
|---|---|---|
--copy-source-if-match | string | Copy the data only if the ETag of the source object matches the specified value. Returns 412 Precondition Failed if the condition is not met. |
--copy-source-if-modified-since | string | Copy the data only if the source object was modified after the specified time. Returns 200 OK if the condition is met; otherwise returns 304 Not Modified. |
--copy-source-if-none-match | string | Copy the data only if the ETag of the source object does not match the specified value. Returns 200 OK if the condition is met; otherwise returns 304 Not Modified. |
--copy-source-if-unmodified-since | string | Copy the data only if the source object was not modified after the specified time. Returns 200 OK if the condition is met; otherwise returns 412 Precondition Failed. |
--copy-source-range | string | Byte range to copy from the source object. Format: bytes=first-last (zero-based byte offsets). For example, bytes=0-9 copies the first 10 bytes. |
--metadata-directive | string | Method used to set the metadata of the destination object |
--tagging | string | Tags to apply to the destination object |
--tagging-directive | string | Method used to set the tags of the destination object |
Note: For supported global flags, see Global command-line options.
Examples
Copy data from a source object as a part
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1Copy data in JSON output format
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1 --output-format jsonCopy data in YAML output format
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1 --output-format yamlCopy a byte range from the source object
Copy bytes 0 through 9 (the first 10 bytes) from srcobject:
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1 --copy-source-range bytes=0-9Copy data with an ETag condition
Copy the data only if the ETag of srcobject is 123:
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1 --copy-source-if-match 123Copy data with an unmodified-since condition
Copy the data only if srcobject was not modified after Mon, 11 May 2020 08:16:23 GMT:
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1 --copy-source-if-unmodified-since "Mon, 11 May 2020 08:16:23 GMT"Copy data and replace object tags
Copy the data and replace the source object's tags with the specified tags:
ossutil api upload-part-copy --bucket examplebucket --key exampleobject --copy-source /srcbucket/srcobject --upload-id 123 --part-number 1 --tagging-directive Replace --tagging "TagA=A&TagB=B"What's next
The upload-part-copy command corresponds to the UploadPartCopy API operation. For full parameter details, see the API reference.
To complete a multipart upload workflow, use the following commands in sequence:
initiate-multipart-upload — Initiate a multipart upload and get an upload ID
upload-part-copy (this command) — Copy an existing object as a part
complete-multipart-upload — Combine all uploaded parts into the final object
abort-multipart-upload — Cancel a multipart upload and free storage
list-parts — List all parts uploaded under an upload ID