Example 2: Recovering an old version of an object

Here’s a sample PUT request that copies an old version of an object to the same object, thereby creating a new current version from the old version. The object in question is named AcctgBestPractices.doc and is in the finance bucket. The version ID of the version being copied is 87288808614529. The request is being made while versioning is enabled for the bucket.

Request with s3curl command line

./s3curl.pl --id=lgreen
     --copysrc=/finance/ AcctgBestPractices.doc?versionId=87288808614529 -- -k
     "https://finance.europe.hcp.example.com/AcctgBestPractices.doc"
     -H "x-hcp-pretty-print: true"

Request headers

PUT /AcctgBestPractices.doc HTTP/1.1
Host: finance.europe.hcp.example.com
Date: Fri, 07 February 2020 17:19:26 +0000
Authorization: AWS bGdyZWVu:AZ/GOgJJXFh7K1pr59bIlwRUrc0=
x-amz-copy-source: /finance/AcctgBestPractices.doc?versionId=87288808614529
x-hcp-pretty-print: true

Response headers

HTTP/1.1 200 OK
Date: Fri, 07 February 2020 17:19:26 GMT
x-amz-version-id: 87288815588289
ETag: "764f38262c6e581f678e1ac9b0211ae8"
x-amz-copy-source-version-id: 87288808614529
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.000Z</LastModified>
     <ETag>"764f38262c6e581f678e1ac9b0211ae8"</ETag>
</CopyObjectResult>

© 2015, 2020 Hitachi Vantara LLC. All rights reserved.