def sign_policy_document(policy_document): """ Sign and return the policy doucument for a simple upload. http://aws.amazon.com/articles/1434/#signyours3postform """ policy = base64.b64encode(json.dumps(policy_document).encode('utf-8')) signature = base64.b64encode(sign(policy)) return { 'policy': str(policy, 'ascii'), 'signature': str(signature, 'ascii'), }
def sign_headers(headers): """ Sign and return the headers for a chunked upload. """ header_bytes = headers.encode('utf-8') return { 'signature': str(base64.b64encode(sign(header_bytes)), 'ascii'), }