HCP Tenant Management Help


Example 1: Conditionally copying an object from one bucket to another

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 an ETag of 7ad452af1e2f61b33a865c4362be5921. The request directs HCP to perform the copy operation only if the ETag of the source object doesn't match the ETag of the most recent version 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.com/mktg/campaign_GoGetEm_expenses.xls"
     -H "x-amz-copy-source-if-none-match:7ad452af1e2f61b33a865c4362be5921"
     -H "x-hcp-pretty-print: true"

Request headers

PUT /mktg/campaign_GoGetEm_expenses.xls HTTP/1.1
Host: finance.europe.hcp.example.com
Date: Fri, 10 May 2019 17:19:26 +0000
Authorization: AWS bGdyZWVu:oBVRqkcjktavqo6z1m+chHhRmmI=
x-amz-copy-source: /sales-mktg/campaigns/GoGetEm.xls
x-amz-copy-source-if-none-match:7ad452af1e2f61b33a865c4362be5921
x-hcp-pretty-print: true

Response headers

HTTP/1.1 200 OK
Date: Fri, 10 May 2019 17:19:26 GMT
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>2017-02-23T17:19:26.402Z</LastModified>
     <ETag>"6ed7faad1e0661c03ad65a4317d4a94c"</ETag>
</CopyObjectResult>

© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.