Copying an object example

Here’s a sample HTTP PUT request that copies an object named Q1_2012.ppt from the default namespace if the source object has been modified since midnight, Tuesday, January 1, 2013 EST. The request stores the object, using the source object name, in the finance namespace .

Request with curl command line

curl -k -i -X PUT
    -H "Authorization: HCP bXl1c2Vy:3f3c6784e97531774380db177774ac8d"
    -H "X-HCP-CopySource: default.europe/quarterly_rpts/Q1_2012.ppt"
    -H "X-HCP-CopySource-If-Modified-Since: Tue, Jan 1 2013 05:00:00 GMT"
    "https://finance.europe.hcp.example.com/rest/quarterly_rpts/Q1_2012.ppt"

Request in Python using PycURL

import pycurl
import os
headers = ["Authorization: HCP
               bXl1c2Vy:3f3c6784e97531774380db177774ac8d",
           "X-HCP-CopySource: default.europe/quarterly_rpts/ \
               Q1_2012.ppt",
           "X-HCP-CopySource-If-Modified-Since:
               Tue, Jan 1 2013 05:00:00 GMT"
curl = pycurl.Curl()
curl.setopt(pycurl.URL, "https://finance.europe.hcp.example.com/ \
  rest/quarterly_rpts/Q1_2012.ppt")
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
curl.setopt(pycurl.HTTPHEADER, headers)
curl.setopt(pycurl.PUT, 1)
curl.setopt(pycurl.INFILESIZE, 0
curl.perform()
print curl.getinfo(pycurl.RESPONSE_CODE)
curl.close()

 

Request headers

PUT /rest/quarterly_rpts/Q1_2012.ppt HTTP/1.1
Host: /finance.europe.hcp.example.com
Authorization: HCP bXl1c2Vy:3f3c6784e97531774380db177774ac8d
X-HCP-CopySource: default.europe/quarterly_rpts/Q1_2012.ppt
X-HCP-If-Modified-Since: Tue, Jan 01 2013 05:00:00 GMT"
Content-Length: 678400

Response headers

HTTP/1.1 201 Created
X-HCP-ServicedBySystem: hcp.example.com
Location: /rest/quarterly_rpts/Q1_2012.ppt
ETag: "9c604138ffb0f308a8552a3752e5a1be"
X-HCP-VersionId: 86675191823873
X-HCP-Hash: SHA-256 E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934C...
X-HCP-Time: 1354299872
Content-Length: 0

Trademark and LegalDisclaimer

© 2016 Hitachi Data Systems Corporation. All rights reserved.