Classic/VPC環境で利用できます。
バケットにオブジェクトをアップロードしたり、既にアップロードしたオブジェクトをローカルにダウンロードまたは別の場所にコピーしたりします。
構文
cp構文は次の通りです。
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>
オプション
cpの実行時に指定できるオプションについて説明します。
必須オプション
cpの必須オプションです。
| オプション | タイプ | 必須の有無 | 説明 |
|---|---|---|---|
<source> |
String | Required | 元のパス
|
<destination> |
String | Required | コピー先のパス
|
任意オプション
cpの任意オプションです。指定しない場合、オプションにはデフォルト値が適用されます。
| オプション | タイプ | 必須の有無 | 説明 |
|---|---|---|---|
--dryrun |
Boolean | Optional | コマンドを実行せずに結果だけを確認 |
--quiet |
Boolean | Optional | レスポンス結果を表示しない |
--include |
String | Optional | 指定したパターンと一致するオブジェクトのみがコマンドに含める
|
--exclude |
String | Optional | 指定したパターンと一致するオブジェクトをコマンドから除外
|
--recursive |
Boolean | Optional | 指定したパスの配下の項目までコピー |
--acl |
String | Optional | オブジェクトに適用するアクセス制御リスト
|
--follow-symlinks, --no-follow-symlinks |
Boolean | Optional | シンボリックリンクが指すファイルのコンテンツをアップロードするか
|
--no-guess-mime-type |
Boolean | Optional | アップロードするオブジェクトのコンテンツタイプの自動推測を無効化 |
--content-type |
String | Optional | 明示的なコンテンツタイプ定義 |
--only-show-errors |
Boolean | Optional | エラーのみ表示し、その他のレスポンス値は表示しない |
--no-progress |
Boolean | Optional | ファイル転送の進捗率を表示しない
|
--page-size |
Integer | Optional | ページごとの項目数
|
--metadata |
String | Optional | オブジェクトと併せて保存するメタデータを設定 |
--metadata-directive |
String | Optional | コピー時のメタデータ処理方式
|
共通オプション
awsコマンドで共通して使用するオプションについては、Object Storageのオプションをご参照ください。
例
リクエストが成功すると、コピーされたオブジェクトのコピー元のパスとコピー先のパスが表示されます。
コマンド
オブジェクトをアップロードするコマンドの例は次の通りです。
aws s3 cp sample.txt s3://my-test-bucket/sample.txt \
--endpoint-url=https://kr.object.ncloudstorage.com
オブジェクトをダウンロードするコマンドの例は次の通りです。
aws s3 cp s3://my-test-bucket/sample.txt sample.txt \
--endpoint-url=https://kr.object.ncloudstorage.com
ディレクトリ全体をアップロードするコマンドの例は次の通りです。
aws s3 cp docs s3://my-test-bucket/docs \
--recursive \
--endpoint-url=https://kr.object.ncloudstorage.com
出力
オブジェクトをアップロードする出力の例は次の通りです。
Completed 46 Bytes/46 Bytes (185 Bytes/s) with 1 file(s) remaining
upload: ./sample.txt to s3://my-test-bucket/sample.txt
オブジェクトをダウンロードする出力の例は次の通りです。
Completed 46 Bytes/46 Bytes (688 Bytes/s) with 1 file(s) remaining
download: s3://my-test-bucket/sample.txt to ./sample.txt
ディレクトリ全体をアップロードする出力の例は次の通りです。
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