/usr/share/doc/python-awsauth/examples/example.py is in python-awsauth 0.1.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #!/usr/bin/env python
import requests
from awsauth import S3Auth
import StringIO
import gzip
import urllib
ACCESS_KEY = "ACCESSKEYXXXXXXXXXXXX"
SECRET_KEY = "AWSSECRETKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
acceptableAccessCodes = (200, 204) # # https://forums.aws.amazon.com/thread.jspa?threadID=28799: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectDELETE.html
if __name__ == '__main__':
confirmIt = u'Sam is sweet' # Data needs to be in unicode, or it will fail
bucketName = 'mybucket'
objectName = ['myfile.txt', 'my+file.txt']
for o in objectName:
# Creating a file
r = requests.put(('http://%s.s3.amazonaws.com/%s' % (bucketName, o)), data=confirmIt, auth=S3Auth(ACCESS_KEY, SECRET_KEY))
if r.status_code not in acceptableAccessCodes:
r.raise_for_status()
# Downloading a file
r = requests.get(('http://%s.s3.amazonaws.com/%s' % (bucketName, o)), auth=S3Auth(ACCESS_KEY, SECRET_KEY))
if r.status_code not in acceptableAccessCodes:
r.raise_for_status()
if r.content == confirmIt:
print 'Hala Madrid!'
# Removing a file
r = requests.delete(('http://%s.s3.amazonaws.com/%s' % (bucketName, o)), auth=S3Auth(ACCESS_KEY, SECRET_KEY))
if r.status_code not in acceptableAccessCodes:
r.raise_for_status()
|