Merge "Add --quoted option to swift-temp-url"
This commit is contained in:
commit
c384d76c57
@ -17,10 +17,11 @@ from hashlib import sha1
|
||||
from os.path import basename
|
||||
from sys import argv, exit, stderr
|
||||
from time import time
|
||||
import urllib
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(argv) != 5:
|
||||
if len(argv) < 5:
|
||||
prog = basename(argv[0])
|
||||
print 'Syntax: %s <method> <seconds> <path> <key>' % prog
|
||||
print
|
||||
@ -45,7 +46,7 @@ if __name__ == '__main__':
|
||||
'temp_url_sig=34d49efc32fe6e3082e411eeeb85bd8a&' \
|
||||
'temp_url_expires=1323482948'
|
||||
exit(1)
|
||||
method, seconds, path, key = argv[1:]
|
||||
method, seconds, path, key = argv[1:5]
|
||||
try:
|
||||
expires = int(time() + int(seconds))
|
||||
except ValueError:
|
||||
@ -64,6 +65,10 @@ if __name__ == '__main__':
|
||||
'(e.g. /v1/account/container/object).\n' % path)
|
||||
stderr.write(
|
||||
'WARNING: Non-object paths will be rejected by tempurl.\n')
|
||||
sig = hmac.new(key, '%s\n%s\n%s' % (method, expires, path),
|
||||
if '--quoted' in argv[5:]:
|
||||
real_path = urllib.unquote(path)
|
||||
else:
|
||||
real_path = path
|
||||
sig = hmac.new(key, '%s\n%s\n%s' % (method, expires, real_path),
|
||||
sha1).hexdigest()
|
||||
print '%s?temp_url_sig=%s&temp_url_expires=%s' % (path, sig, expires)
|
||||
|
Loading…
Reference in New Issue
Block a user