cp

Prev Next

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 <pattern>] \
    [--exclude <pattern>] \
    [--recursive] \
    [--acl <acl>] \
    [--follow-symlinks | --no-follow-symlinks] \
    [--no-guess-mime-type] \
    [--content-type <content-type>] \
    [--only-show-errors] \
    [--no-progress] \
    [--page-size <page-size>] \
    [--metadata <metadata>] \
    [--metadata-directive <COPY|REPLACE>] \
    --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
  • Local path or S3 URI in the format of s3://{bucket_name}[/{object_name}]
<destination> String Required Destination path
  • Local path or S3 URI in the format of s3://{bucket_name}[/{object_name}]

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.
  • Applied in the specified order.
--exclude String Optional Excludes objects matching the specified pattern from the command.
  • Applied in the specified order.
--recursive Boolean Optional Copies items in subdirectories of the specified path.
--acl String Optional List of access controls to apply to the object
  • private | public-read | public-read-write | authenticated-read
--follow-symlinks, --no-follow-symlinks Boolean Optional Whether to upload the content of files pointed to by symbolic links
  • Default: --follow-symlinks
  • Applies only when uploading objects from the local file system.
--no-guess-mime-type Boolean Optional Disables automatic guessing of the content type for objects to be uploaded.
--content-type String Optional Define explicit content type.
--only-show-errors Boolean Optional Displays only errors; other response values are not displayed.
--no-progress Boolean Optional Does not display file transfer progress
  • Not applied if --quiet or --only-show-errors is specified
--page-size Integer Optional Number of items per page
  • 1-1000
--metadata String Optional Set up metadata to store with the object.
--metadata-directive String Optional Metadata handling options when copying
  • COPY (default) | REPLACE
    • COPY: Copies original.
    • REPLACE: Redefines.

Common options

For information about the options common to all aws subcommands, see Object Storage options.

Examples

If the request is successful, the source and destination paths of the copied object are displayed.

Command

The following is an example command for uploading an object.

aws s3 cp sample.txt s3://my-test-bucket/sample.txt \
    --endpoint-url=https://kr.object.ncloudstorage.com

The following is an example command for downloading an object.

aws s3 cp s3://my-test-bucket/sample.txt sample.txt \
    --endpoint-url=https://kr.object.ncloudstorage.com

The following is a example command for uploading an entire directory.

aws s3 cp docs s3://my-test-bucket/docs \
    --recursive \
    --endpoint-url=https://kr.object.ncloudstorage.com

Output

The following is an example output for uploading an object.

Completed 46 Bytes/46 Bytes (185 Bytes/s) with 1 file(s) remaining
upload: ./sample.txt to s3://my-test-bucket/sample.txt

The following is an example output for downloading an object.

Completed 46 Bytes/46 Bytes (688 Bytes/s) with 1 file(s) remaining
download: s3://my-test-bucket/sample.txt to ./sample.txt

The following is an example output for uploading an entire directory.

Completed 41 Bytes/41 Bytes (468 Bytes/s) with 1 file(s) remaining
upload: docs/report.txt to s3://my-test-bucket/docs/report.txt