S3 · Objects
CopyObject
/{bucket}/{key}with the x-amz-copy-source headerCopies an object to another key.
Storage copies the bytes on its side, with no download. The source can be in another bucket of the same workspace. The copy keeps the metadata and tags of the source unless you replace them.
- Role
- Editor or higher
- Support
- Partial
- The source needs the Viewer role and must be in the same workspace. A copy across storage providers returns 501.
- The key needs the Viewer role on the source and the Editor role on the target.
- Storage does not check the
x-amz-copy-source-if-*conditions.
Path parameters
Headers
The source, as {bucket}/{key}, URL-encoded. Add ?versionId= to copy one version.
Whether to keep the metadata of the source or to use the headers of this request.
Default: "COPY"
- COPY
- Keep the metadata of the source.
- REPLACE
- Use Content-Type, the stored headers, and
x-amz-meta-*from this request.
Whether to keep the tags of the source.
Default: "COPY"
- COPY
- Keep the tags of the source.
- REPLACE
- Use the tags in
x-amz-tagging.
The media type of the copy. Used with REPLACE.
Stored with the object and returned on reads. Used with REPLACE.
Stored with the object and returned on reads. Used with REPLACE.
Stored with the object and returned on reads. Used with REPLACE.
Stored with the object and returned on reads. Used with REPLACE.
User metadata. Used with REPLACE.
Recorded with the object and shown in listings. Used with REPLACE.
Tags for the object, as a URL query. For example, team=support&tier=gold. Used with a tagging directive of REPLACE.
The workspace ID that must own the bucket. Another owner returns 403 AccessDenied.
Responses
200OK
Storage wrote the copy.
application/xml
The root element.
LastModifiedstringWhen the copy was written.
ETagstringThe entity tag of the copy.
Errors
Select an error in the response example to see its XML body. Any request can also get the common errors, such as SignatureDoesNotMatch.
- 400InvalidRequest
The
x-amz-copy-sourcevalue is not{bucket}/{key}.What to do: Send the source as
{bucket}/{key}, URL-encoded.- 404NoSuchKey
The source has no object at this key or version.
What to do: Check the key and the versionId.
- 404NoSuchBucket
The source bucket or the target bucket does not exist.
What to do: Check the bucket name. ListBuckets shows the buckets of the workspace.
- 403AccessDenied
The key cannot read the source or write the target, or the source is in another workspace.
What to do: Use a key of the workspace that owns the bucket, with the role above.
- 501NotImplemented
The source bucket uses another storage provider.
What to do: Copy between buckets of the same provider, or download and upload the object.
- 405MethodNotAllowed
The versionId names a delete marker, which has no bytes.
What to do: Use the versionId of a version that holds data. ListObjectVersions shows each one.
- 503SlowDown
The bucket has too many writes in progress. The response has
Retry-After: 1.What to do: Wait for the Retry-After time, then send the request again. SDKs retry by themselves.