| 1 | #S3 using python-requests |
| 2 | |
| 3 | AWS authentication for Amazon S3 for the wonderful [pyhon requests library](http://python-requests.org) |
| 4 | |
| 5 | - Tested with python 2.6 and python 3.3.2 |
| 6 | - At the moment only S3 is supported |
| 7 | |
| 8 | ## Usage |
| 9 | |
| 10 | |
| 11 | ```python |
| 12 | import requests |
| 13 | from awsauth import S3Auth |
| 14 | |
| 15 | ACCESS_KEY = 'ACCESSKEYXXXXXXXXXXXX' |
| 16 | SECRET_KEY = 'AWSSECRETKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' |
| 17 | |
| 18 | s = 'Sam is sweet' |
| 19 | # Creating a file |
| 20 | r = requests.put('http://mybuck.s3.amazonaws.com/file.txt', data=s, auth=S3Auth(ACCESS_KEY, SECRET_KEY)) |
| 21 | |
| 22 | # Downloading a file |
| 23 | r = requests.get('http://mybuck.s3.amazonaws.com/file.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY)) |
| 24 | if r.text == 'Sam is sweet': |
| 25 | print "It works" |
| 26 | |
| 27 | # Removing a file |
| 28 | r = requests.delete('http://mybuck.s3.amazonaws.com/file.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY)) |
| 29 | |
| 30 | ``` |
| 31 | |
| 32 | ## Installation |
| 33 | Installing requests-aws is simple with pip: |
| 34 | |
| 35 | ``` |
| 36 | $ pip install requests-aws |
| 37 | ``` |
| 38 | |
| 39 | [](https://travis-ci.org/tax/python-requests-aws) |