-
Notifications
You must be signed in to change notification settings - Fork 127
Using COPY
The syntax for copying objects is a bit difficult. It's because COPY was added later (by Amazon), and squeezed into an existing protocol.
The syntax is
aws copy destination-bucket/destination-object source
The target must be a destination bucket and destination object. The source optionally contains a bucket name. If the source starts with a slash, then it is taken to be a bucket/key. Otherwise, it is taken to be a key, and will be copied into the same bucket as the destination. Thus,
aws copy test682/hello2.txt hello.txt
aws copy test682/hello2.txt /test682/hello.txt
both copy test682/hello.txt to test682/hello2.txt. To copy from a different bucket,
aws copy test682/hello2.txt /test681/hello.txt
Some people misunderstand what happens when you say, without the leading slash,
aws copy test682/hello2.txt test681/hello.txt
This command copies to test682/hello2.txt. However, because of the missing initial slash, the source is taken to be a key only, appended to the target bucket. Thus, the source is test682/test681/hello.txt (bucket test682, key test681/hello.txt). If you make this mistake, you'll likely see "The specified key does not exist."