diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2011-04-01 12:36:30 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2011-04-01 12:36:30 +0300 |
| commit | d71a2bc0cf6a14523d51828d5d1ad47075bbdb3f (patch) | |
| tree | f2256791fc267815e85fadeeb65a50f3d554b1e0 /s3/gen_policy.py | |
| parent | 9c04e8c4d1353a73103f67413c8ea426bdb6beb6 (diff) | |
added s3 stuff
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 |
