Copy object

 
MethodURIDescription
COPY/v1/{account}/{container}/{object}

Copies an object to another object in the object store.

You can copy an object to a new object with the same name. Copying to the same name is an alternative to using POST to add metadata to an object. With POST, you must specify all the metadata. With COPY, you can add additional metadata to the object.

Alternatively, you can use PUT with the X-Copy-From request header to accomplish the same operation as the COPY object operation.

The PUT operation always creates a new object. If you use this operation on an existing object, you replace the existing object and metadata rather than modifying the object. Consequently, this operation returns a 201 Created success node.

If you use this operation to copy a manifest object, the new object is a normal object and not a copy of the manifest. Instead it is a concatenation of all the segment objects. This means that you cannot copy objects larger than 5 GB in size. All metadata is preserved during the object copy. If you specify metadata on the request to copy the object, either PUT or COPY, the metadata overwrites any conflicting keys on the target (new) object.

Example requests and responses:

  • Copy the goodbye object from the marktwain container to the janeausten container: curl -i $publicURL/marktwain/goodbye -X COPY -H "X-Auth-Token: $token" -H "Destination: janeausten/goodbye"

    HTTP/1.1 201 Created
    Content-Length: 0
    X-Copied-From-Last-Modified: Thu, 16 Jan 2014 21:19:45 GMT
    X-Copied-From: marktwain/goodbye
    Last-Modified: Fri, 17 Jan 2014 18:22:57 GMT
    Etag: 451e372e48e0f6b1114fa0724aa79fa1
    Content-Type: text/html; charset=UTF-8
    X-Object-Meta-Movie: AmericanPie
    X-Trans-Id: txdcb481ad49d24e9a81107-0052d97501
    Date: Fri, 17 Jan 2014 18:22:57 GMT

  • Alternatively, you can use PUT to copy the goodbye object from the marktwain container to the janeausten container. This request requires a Content-Length header even if it is set to zero (0).

    curl -i $publicURL/janeausten/goodbye -X PUT -H "X-Auth-Token: $token" -H "X-Copy-From: /marktwain/goodbye" -H "Content-Length: 0"

    HTTP/1.1 201 Created
    Content-Length: 0
    X-Copied-From-Last-Modified: Thu, 16 Jan 2014 21:19:45 GMT
    X-Copied-From: marktwain/goodbye
    Last-Modified: Fri, 17 Jan 2014 18:22:57 GMT
    Etag: 451e372e48e0f6b1114fa0724aa79fa1
    Content-Type: text/html; charset=UTF-8
    X-Object-Meta-Movie: AmericanPie
    X-Trans-Id: txdcb481ad49d24e9a81107-0052d97501
    Date: Fri, 17 Jan 2014 18:22:57 GMT

For a complete description of HTTP 1.1 header definitions, see Header Field Definitions.

[Note]Note

When several replicas exist, the system copies from the most recent replica. That is, the COPY operation behaves as though the X-Newest header is in the request.

Normal response codes: 201

 Request

This table shows the header parameters for the copy object request:

NameTypeDescription

X-Auth-Token

​String

(Optional)

Authentication token. If you omit this header, your request fails unless the account owner has granted you access through an access control list (ACL).

Destination

​String

(Required)

The container and object name of the destination object in the form of /container/object. You must UTF-8-encode and then URL-encode the names of the destination container and object before you include them in this header.

Content-Type

​String

(Optional)

Changes the MIME type for the object.

Content-Encoding

​String

(Optional)

If set, the value of the Content-Encoding metadata.

Content-Disposition

​String

(Optional)

If set, specifies the override behavior for the browser. For example, this header might specify that the browser use a download program to save this file rather than show the file, which is the default.

X-Object-Meta-name

​String

(Optional)

The container metadata, where {name} is the name of the metadata item.

You must specify a X-Object-Meta-{name} header for each metadata item (for each {name}) that you want to add or update.

This table shows the URI parameters for the copy object request:

NameTypeDescription

{account}

​String

The unique name for the account. An account is also known as the project or tenant.

{container}

​String

The unique name for the container.

{object}

​String

The unique name for the object.

 Response

This table shows the header parameters for the copy object response:

NameTypeDescription

Content-Length

​String

(Required)

If the operation succeeds, this value is zero (0). If the operation fails, this value is the length of the error text in the response body.

X-Copied-From-Last-Modified

​String

(Optional)

For a copied object, shows the last modified date and time for the container and object name from which the new object was copied.

X-Copied-From

​String

(Optional)

For a copied object, shows the container and object name from which the new object was copied. The value is in form {container}/{object}.

Last-Modified

​String

(Required)

The date and time that the object was created or the last time that the metadata was changed.

ETag

​String

(Required)

The MD5 checksum of the copied object content. The value is not quoted.

Content-Type

​String

(Required)

The MIME type of the object.

X-Object-Meta-name

​String

(Required)

The custom object metadata item, where {name} is the name of the metadata item.

One X-Object-Meta-{name} response header appears for each metadata item (for each {name}).

X-Trans-Id

​Uuid

(Required)

A unique transaction identifier for this request. Your service provider might need this value if you report a problem.

Date

​Datetime

(Required)

The transaction date and time.

Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page

loading table of contents...