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 <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
  • 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.
--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.
--storage-class String Optional Specifies the storage class for the object.
  • STANDARD (default) | ONEZONE_IA | DEEP_ARCHIVE
--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
  • Not applied if --quiet or --only-show-errors is specified
--page-size Integer Optional Number of items per page
  • 1-1000
--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.
  • none | metadata-directive | default (default)
    • none: Does not copy attributes.
    • metadata-directive: Copies content-related attributes and metadata.
    • default: Copies and adds tags to attributes targeted by metadata-directive.
  • Applies only when copying from Ncloud Storage to Ncloud Storage.
--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 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