import requests
from awsauth import S3Auth

INTEROUTE_S3_KEY = 'XXXXXXXXX'
INTEROUTE_S3_SECRET = 'XXXXXXXXX'

OSauth = S3Auth(INTEROUTE_S3_KEY, INTEROUTE_S3_SECRET, service_url='s3-eu.object.vdc.interoute.com')

# Load the CORS configuration from file 'CORS.cfg' and calculate the encoded MD5 checksum
with open('CORS.cfg') as fh:
   corsConfig = fh.read()
corsMD5hash = hashlib.md5()
corsMD5hash.update(corsConfig)
corsMD5encoded = base64.b64encode(corsMD5hash.digest())

# PUT the CORS configuration to an existing bucket (replace 'mybucket' with an actual bucket name)
## requests.put('http://mybucket.s3-eu.object.vdc.interoute.com/?cors', auth=OSauth, data=corsConfig, headers={'content-md5':corsMD5encoded})

# PUT a new object into an existing bucket (replace 'mybucket' with an actual bucket name)
## objecttext = 'The purpose of the object'
## requests.put('http://mybucket.s3-eu.object.vdc.interoute.com/testobject.txt', auth=OSauth, data=objecttext)

# GET contents of an object (replace 'mybucket' with an actual bucket name)
## r1 = requests.get('http://mybucket.s3-eu.object.vdc.interoute.com/testobject.txt', auth=OSauth)




@@ -35,16 +35,45 @@
 t S3Auth
+%0Aimport base64%0Aimport hashlib
 %0A%0AINTERO

update for new version of the Object Storage API User Guide