Available in Classic and VPC
Copy an object to a new location. If you do not specify a destination, only the object's metadata is changed.
Syntax
The copy syntax is as follows:
swift copy \
<container> \
<object> \
[--destination <destination-path>] \
[--fresh-metadata] \
[--meta <name:value>] \
[--header <header:value>]
Options
This section describes the options available when running copy.
Required options
The following options are required for copy.
| Options | Type | Required | Description |
|---|---|---|---|
<container> |
String | Required | Container name |
<object> |
List | Required | Object name
|
Optional options
These are the optional options for copy. Options that are not specified will use their default values.
| Options | Type | Required | Description |
|---|---|---|---|
--destination |
String | Optional | Container and object names to copy
|
--fresh-metadata |
Boolean | Optional | Copy excluding existing metadata.
|
--meta |
String | Optional | Metadata entry
|
--header |
String | Optional | Custom header to use in the request
|
Common options
For information about the options common to all swift subcommands, see Archive Storage options.
Examples
When you run the command, the source object and destination path are displayed.
Command
The command example is as follows:
swift copy test-container-01 sample.txt \
--destination /test-container-01/copied.txt
Output
The output example is as follows:
created container test-container-01
test-container-01/sample.txt copied to /test-container-01/copied.txt