diff options
author | Paul Tax <paultax@gmail.com> | 2013-09-27 11:32:56 -0700 |
---|---|---|
committer | Paul Tax <paultax@gmail.com> | 2013-09-27 11:32:56 -0700 |
commit | b4ab2349b63d92d08ef799a700ba568f233d491d (patch) | |
tree | 9685356b2f8ee793ac22aac15082834f967a9051 | |
parent | d6e637cfeb6df8d1fc3e40d4d40fe815d9f9fabe (diff) | |
parent | a39059030d511eddb70500bc9fa01df3d38f2905 (diff) | |
download | python-requests-aws-b4ab2349b63d92d08ef799a700ba568f233d491d.tar.gz |
Merge pull request #6 from matheuspatury/master
fix issues to work in Python 3.3.2
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | awsauth.py | 6 |
2 files changed, 12 insertions, 8 deletions
@@ -2,7 +2,7 @@ AWS authentication for Amazon S3 for the wonderful [pyhon requests library](http://python-requests.org) -- Tested with python 2.6 +- Tested with python 2.6 and python 3.3.2 - At the moment only S3 is supported ## Usage @@ -17,15 +17,15 @@ SECRET_KEY = 'AWSSECRETKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' s = 'Sam is sweet' # Creating a file -r = requests.put('http://mybucket.s3.amazonaws.com/file.txt', data=s, auth=S3Auth(ACCESS_KEY, SECRET_KEY)) +r = requests.put('http://mybuck.s3.amazonaws.com/file.txt', data=s, auth=S3Auth(ACCESS_KEY, SECRET_KEY)) # Downloading a file -r = requests.get('http://mybucket.s3.amazonaws.com/file.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY)) -if r.content == 'Sam is sweet': - print 'Hala Madrid!' +r = requests.get('http://mybuck.s3.amazonaws.com/file.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY)) +if r.text == 'Sam is sweet': + print "It works" # Removing a file -r = requests.delete('http://mybucket.s3.amazonaws.com/file.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY)) +r = requests.delete('http://mybuck.s3.amazonaws.com/file.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY)) ``` @@ -36,4 +36,4 @@ Installing requests-aws is simple with pip: $ pip install requests-aws ``` -[](https://travis-ci.org/tax/python-requests-aws)
\ No newline at end of file +[](https://travis-ci.org/tax/python-requests-aws) @@ -6,9 +6,13 @@ from hashlib import sha1 as sha py3k = False try: from urlparse import urlparse + from base64 import encodestring + except: py3k = True from urllib.parse import urlparse + from base64 import encodebytes as encodestring + from email.utils import formatdate from requests.auth import AuthBase @@ -57,7 +61,7 @@ class S3Auth(AuthBase): key = self.secret_key msg = canonical_string h = hmac.new(key, msg, digestmod=sha) - return base64.encodestring(h.digest()).strip() + return encodestring(h.digest()).strip() def get_canonical_string(self, url, headers, method): parsedurl = urlparse(url) |