Skip to main content

tcb storage objects cp

Copy an object to a new location, across buckets if needed.

v3.4.0+

PG mode storage commands have been available since @cloudbase/cli@3.4.0.

Usage​

tcb storage objects cp <srcKey> <dstKey> -b <bucketId> [options]

Parameters​

ParameterRequiredDescriptionDefault
<srcKey>YesSource object name—
<dstKey>YesTarget object name—
-b, --bucket <bucketId>YesSource Bucket ID—
--dst-bucket <bucketId>NoTarget Bucket IDSame as the source bucket
--copy-metadata <bool>NoWhether to copy the source metadatatrue
--metadata <json>NoSystem metadata JSON merged with the source metadata; COS only recognises cacheControl / mimetype / contentType—
--user-metadata <json>NoUser metadata JSON that replaces the target user_metadata entirely—
--upsertNoAllow overwriting an existing object at the targetfalse
--jsonNoOutput the raw SDK result ICopyObjectHttpResult—

Validation rules:

  • Within the same bucket, a source key equal to the target key without --upsert fails with INVALID_PARAM.
  • --metadata / --user-metadata only take effect together with --copy-metadata false; the CLI rejects them otherwise.

Examples​

tcb storage objects cp test/hello.txt test/hello-copy.txt -b my-bucket
tcb storage objects cp test/hello.txt backup/hello.txt -b my-bucket --dst-bucket backup-bucket