Conditionally copying an object from one bucket to another example

Here’s a sample PUT request that conditionally copies the current version of an object named campaigns/GoGetEm.xls from the sales-mktg bucket to the finance bucket, where the target object that results from the copy operation is named mktg/campaign_GoGetEm_expenses.xls. The request is being made while versioning is enabled for both the source and target buckets.

For the purpose of this example, assume that mktg/campaign_GoGetEm_expenses.xls already exists in the target bucket with a last-modified date and time of Tuesday, February 12, 2013, at 10:14:06 GMT. The request says to perform the copy operation only if the last-modified date and time of the source object is later than the last-modified date and time of the target object.

Request with s3curl command line

./s3curl.pl --id=lgreen --copysrc=/sales-mktg/campaigns/GoGetEm.xls -- -k
     "https://finance.europe.hcp.example/mktg/campaign_GoGetEm_expenses.xls"
     -H "x-amz-copy-source-if-modified-since:Tue, 12 Feb 2013 10:14:06 +0000"
     -H "x-hcp-pretty-print:true"

Request headers

PUT /mktg/campaign_GoGetEm_expenses.xls HTTP/1.1
Host: finance.europe.hcp.example.com
Date: Wed, 13 Feb 2013 17:44:53 +0000
Authorization: AWS bGdyZWVu:oBVRqkcjktavqo6z1m+chHhRmmI=
x-amz-copy-source: /sales-mktg/campaigns/GoGetEm.xls
x-amz-copy-source-if-modified-since: Tue, 12 Feb 2013 10:14:06 +0000
x-hcp-pretty-print: true

Response headers

HTTP/1.1 200 OK
Date: Wed, 13 Feb 2013 17:44:53 GMT
Server: HCP V7.0.0.16
x-amz-version-id: 87288825190337
ETag: "6ed7faad1e0661c03ad65a4317d4a94c"
x-amz-copy-source-version-id: 87388217426433
Content-Type: application/xml;charset=UTF-8
Transfer-Encoding: chunked

Response body

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CopyObjectResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
     <LastModified>2013-02-13T17:44:53.000Z</LastModified>
     <ETag>"6ed7faad1e0661c03ad65a4317d4a94c"</ETag>
</CopyObjectResult>

Trademark and LegalDisclaimer

© 2015 Hitachi Data Systems Corporation. All rights reserved.