Available in Classic and VPC
Upload an object to a bucket, or download an object that has already been uploaded to local or copy it to another location.
Syntax
The cp syntax is as follows:
aws s3 cp \
<source> \
<destination> \
[--dryrun] \
[--quiet] \
[--include <include>] \
[--exclude <exclude>] \
[--recursive] \
[--follow-symlinks | --no-follow-symlinks] \
[--no-guess-mime-type] \
[--storage-class <storage-class>] \
[--content-type <content-type>] \
[--cache-control <cache-control>] \
[--content-disposition <content-disposition>] \
[--content-encoding <content-encoding>] \
[--content-language <content-language>] \
[--only-show-errors] \
[--no-progress] \
[--page-size <page-size>] \
[--ignore-glacier-warnings] \
[--metadata <metadata>] \
[--copy-props <copy-props>] \
[--metadata-directive <metadata-directive>] \
--endpoint-url <endpoint-url>
Options
This section describes the options available when running cp.
Required options
The following options are required for cp.
| Options | Type | Required | Description |
|---|---|---|---|
<source> |
String | Required | Source path
|
<destination> |
String | Required | Destination path
|
Optional options
These are the optional options for cp. Options that are not specified will use their default values.
| Options | Type | Required | Description |
|---|---|---|---|
--dryrun |
Boolean | Optional | Checks the results of the command without actually executing it. |
--quiet |
Boolean | Optional | Does not display the response. |
--include |
String | Optional | Includes only objects matching the specified pattern in the command.
|
--exclude |
String | Optional | Excludes objects matching the specified pattern from the command.
|
--recursive |
Boolean | Optional | Copies items in subdirectories of the specified path. |
--follow-symlinks, --no-follow-symlinks |
Boolean | Optional | Whether to upload the content of files pointed to by symbolic links
|
--no-guess-mime-type |
Boolean | Optional | Disables automatic guessing of the content type for objects to be uploaded. |
--storage-class |
String | Optional | Specifies the storage class for the object.
|
--content-type |
String | Optional | Define explicit content type. |
--cache-control |
String | Optional | Set caching behavior. |
--content-disposition |
String | Optional | Specifies how to display objects. |
--content-encoding |
String | Optional | Set content encoding. |
--content-language |
String | Optional | Set content language. |
--only-show-errors |
Boolean | Optional | Displays only errors; other response values are not displayed. |
--no-progress |
Boolean | Optional | Does not display file transfer progress
|
--page-size |
Integer | Optional | Number of items per page
|
--ignore-glacier-warnings |
Boolean | Optional | Does not display warnings regarding unsupported operations (such as copying, downloading, or moving) on objects in the Deep Archive. |
--metadata |
String | Optional | Set up metadata to store with the object. |
--copy-props |
String | Optional | Sets the attribute values to copy from the source object.
|
--metadata-directive |
String | Optional | Metadata handling options when copying
|
Common options
For information about the options common to all aws subcommands, see Ncloud Storage options.
Examples
If the request is successful, the source path and destination path are displayed along with the type of job performed.
Command
The following is an example command for uploading a local file to a bucket.
aws s3 cp sample.txt s3://my-test-bucket/docs/sample.txt \
--endpoint-url=https://kr.ncloudstorage.com
The following is an example command for copying an object to a different location within the bucket.
aws s3 cp s3://my-test-bucket/img/image.png s3://my-test-bucket/img/copy.png \
--endpoint-url=https://kr.ncloudstorage.com
The following is an example command for changing an object's storage class.
aws s3 cp s3://my-test-bucket/img/copy.png s3://my-test-bucket/img/copy.png \
--storage-class DEEP_ARCHIVE \
--endpoint-url=https://kr.ncloudstorage.com
The following is an example command for downloading an object from a bucket to your local machine.
aws s3 cp s3://my-test-bucket/docs/sample.txt ./ \
--endpoint-url=https://kr.ncloudstorage.com
Output
The following is an example output for uploading a local file to a bucket.
upload: ./sample.txt to s3://my-test-bucket/docs/sample.txt
The following is an example output for copying an object to a different location within a bucket.
copy: s3://my-test-bucket/img/image.png to s3://my-test-bucket/img/copy.png
The following is an example output for changing an object’s storage class.
copy: s3://my-test-bucket/img/copy.png to s3://my-test-bucket/img/copy.png
The following is an example output for downloading an object from a bucket to your local machine.
download: s3://my-test-bucket/docs/sample.txt to ./sample.txt