Created
March 1, 2013 15:32
-
-
Save chmouel/5065414 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test_client.py | |
import hmac | |
from time import time | |
from hashlib import sha1 | |
import requests | |
MODE = "VM" | |
#var | |
CONF = { | |
'VM': { | |
'account_formdata_key': 'foobar', | |
'account': 'c130b4e303864d0a9e52f02432030d87', | |
'container': 'foobar', | |
'host': 'vm:8080', | |
'htmethod': 'http', | |
'object': 'foo.txt', | |
} | |
} | |
#const | |
max_file_size = 1073741824 | |
seconds = 86400 | |
sample_file = "/tmp/s" | |
#other | |
expires = int(time() + int(seconds)) | |
path = "v1/AUTH_%(account)s/%(container)s/%(object)s" % CONF[MODE] | |
upload_url = '%s://%s/%s' % (CONF[MODE]['htmethod'], | |
CONF[MODE]['host'], | |
path) | |
hmac_body = '%s\n%s\n/%s' % ("GET", expires, path) | |
signature = hmac.new(CONF[MODE]['account_formdata_key'], | |
hmac_body, sha1).hexdigest() | |
full_url = "%s?temp_url_sig=%s&temp_url_expires=%s&filename=attached.txt" % ( | |
upload_url, signature, expires) | |
r = requests.get(full_url) | |
print r.headers['content-disposition'] |
My reading comprehension failed. Ignore me. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What was the output you got you didn't like?