This repository has been archived by the owner on Nov 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 204
Lot of errors at Django S3 example #51
Comments
Now I've converted from byte to str or backwards in every part of the code where I've got errors, but the signature is not correct, because I get a 403 (Forbidden) response from my bucket. |
I don't have any working knowledge of Django. If you are seeing clear issues with the code, a pull request fixing the issues with explanations of the errors and fixes would be much appreciated. Any other issues you see that you are not able to immediately fix can be discussed in that PR as well. |
@andresespinosapc did you find a solution? |
It sounds like you are using Python 3 and the example is for Python 2 |
In my case I had to use
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The first error I've got was at line 54:
request_payload = json.loads(request.body)
, saying that the parameter must be 'str', not 'bytes'. I've fixed it writing this instead:request_payload = json.loads(request.body.decode())
.Then I've got one at line 113:
policy = base64.b64encode(json.dumps(policy_document))
. It said that a bytes-like object was required, not 'str'. So I changed that line topolicy = base64.b64encode(json.dumps(policy_document).encode())
, and it seemed to be fixed.Now I'm getting an error at the next line, 114:
signature = base64.b64encode(hmac.new(settings.AWS_CLIENT_SECRET_KEY, policy, hashlib.sha1).digest())
. At some point of thehmac.new
function I get this:key: expected bytes or bytearray, but got 'str'
.I'll try to fix it, but please tell me if I'm doing something wrong, maybe there's a better way of doing it.
The text was updated successfully, but these errors were encountered: