1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
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
##################
### Or use: http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html
##################
|