cp

Prev Next

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 원본 경로
  • 로컬 경로 또는 s3://{bucket_name}[/{object_name}] 형식의 S3 URI
<destination> String Required 대상 경로
  • 로컬 경로 또는 s3://{bucket_name}[/{object_name}] 형식의 S3 URI

선택 옵션

cp의 선택 옵션입니다. 지정하지 않은 옵션에는 기본값이 적용됩니다.

옵션 타입 필수 여부 설명
--dryrun Boolean Optional 명령을 실제로 실행하지 않고 수행 결과만 확인
--quiet Boolean Optional 응답 결과 미표시
--include String Optional 지정한 패턴과 일치하는 객체만 명령에 포함
  • 지정한 순서대로 적용
--exclude String Optional 지정한 패턴과 일치하는 객체를 명령에서 제외
  • 지정한 순서대로 적용
--recursive Boolean Optional 지정한 경로의 하위 항목까지 복사
--acl String Optional 객체에 적용할 접근 제어 목록
  • private | public-read | public-read-write | authenticated-read
--follow-symlinks, --no-follow-symlinks Boolean Optional 심볼릭 링크가 가리키는 파일의 콘텐츠 업로드 여부
  • 기본값: --follow-symlinks
  • 로컬 파일 시스템에서 객체를 업로드하는 경우에만 해당
--no-guess-mime-type Boolean Optional 업로드할 객체의 콘텐츠 유형 자동 추측 비활성화
--content-type String Optional 명시적인 콘텐츠 유형 정의
--only-show-errors Boolean Optional 에러만 표시하고 다른 응답값은 미표시
--no-progress Boolean Optional 파일 전송 진행률 미표시
  • --quiet 또는 --only-show-errors가 지정된 경우, 미적용
--page-size Integer Optional 페이지당 항목 수
  • 1~1000
--metadata String Optional 객체와 함께 저장할 메타데이터 설정
--metadata-directive String Optional 복사 시 메타데이터 처리 방식
  • COPY (기본값) | REPLACE
    • COPY: 원본 복사
    • REPLACE: 재정의

공통 옵션

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