Example 1: Conditionally creating a part from an object

Here’s a sample PUT request that conditionally uploads a part of the multipart upload for an object named acctg/RulesAndRegulations.pdf in the finance bucket by copying the data from an existing object named acctg/AcctgRR-Summary in the same bucket.

For this example, assume that part 6 of the multipart upload has already been uploaded and has an ETag of 7914d874df2c1d55cfab4fa82088ff56. The request directs HCP to create a new part 6 from the copied data only if the ETag of the copied data is different from the ETag of the data previously uploaded for part 6.

The example shows the response headers HCP returns while versioning is enabled for the bucket.

Request with s3curl command line

./s3curl.pl --id=lgreen --copysrc=finance/acctg/AcctgRR-Summary -- -k
     "https://finance.europe.hcp.example.com/acctg/RulesAndRegulations.pdf
             ?uploadId=94837746087105&partNumber=6"
     -H "x-amz-copy-source-if-none-match:7914d874df2c1d55cfab4fa82088ff56"
     -H "x-hcp-pretty-print: true"

Request headers

PUT /acctg/RulesAndRegulations.pdf?uploadId=94837746087105&partNumber=6 HTTP/1.1
Host: finance.europe.hcp.example.com
Date: Fri, 07 February 2020 17:19:26 +0000
Authorization: AWS bGdyZWVu:PBZDJM2WbzEIX4jFBO4Crah4GMQ=
x-amz-copy-source: finance/acctg/AcctgRR-Summary
x-amz-copy-source-if-none-match:7914d874df2c1d55cfab4fa82088ff56
x-hcp-pretty-print: true

Response headers

HTTP/1.1 200 OK
Date: Fri, 07 February 2020 17:19:26 GMT
ETag: "f79eac0151d6b62226986e721c89a2f1"
x-amz-version-id: 94870864774145
x-amz-copy-source-version-id: 94842948673409
Content-Type: application/xml;charset=UTF-8
x-amz-server-side-encryption: None
Transfer-Encoding: chunked

Response body

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CopyPartResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
     <LastModified>2017-02-23T17:19:26.000Z</LastModified>
     <ETag>"f79eac0151d6b62226986e721c89a2f1"</ETag>
</CopyPartResult>

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