diff options
Diffstat (limited to 's3/gen_policy.py')
| -rw-r--r-- | s3/gen_policy.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/s3/gen_policy.py b/s3/gen_policy.py new file mode 100644 index 0000000..4d0180c --- /dev/null +++ b/s3/gen_policy.py @@ -0,0 +1,21 @@ +import base64 +import hmac, hashlib + +POLICY = """{"expiration": "2012-01-01T00:00:00Z", + "conditions": [ + {"bucket": "AWS_BUCKET_NAME"}, + ["starts-with", "$key", "uploads/"], + {"acl": "private"}, + {"success_action_redirect": "/"}, + ["starts-with", "$Content-Type", ""], + ["content-length-range", 0, 1048576] + ] +}""" + +KEY = "AWS_SECRET_KEY" + +policy = base64.b64encode(POLICY) + +sig = base64.b64encode(hmac.new(KEY, policy, hashlib.sha1).digest()) + +print sig |
