Read host_base config when generating pre signed url
Matt Domsch authored on 2014/03/25 22:17:15... | ... |
@@ -354,12 +354,13 @@ def sign_url_base(**parms): |
354 | 354 |
"""Shared implementation of sign_url methods. Takes a hash of 'bucket', 'object' and 'expiry' as args.""" |
355 | 355 |
parms['expiry']=time_to_epoch(parms['expiry']) |
356 | 356 |
parms['access_key']=Config.Config().access_key |
357 |
+ parms['host_base']=Config.Config().host_base |
|
357 | 358 |
debug("Expiry interpreted as epoch time %s", parms['expiry']) |
358 | 359 |
signtext = 'GET\n\n\n%(expiry)d\n/%(bucket)s/%(object)s' % parms |
359 | 360 |
debug("Signing plaintext: %r", signtext) |
360 | 361 |
parms['sig'] = urllib.quote_plus(sign_string(signtext)) |
361 | 362 |
debug("Urlencoded signature: %s", parms['sig']) |
362 |
- return "http://%(bucket)s.s3.amazonaws.com/%(object)s?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s" % parms |
|
363 |
+ return "http://%(bucket)s.%(host_base)s/%(object)s?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s" % parms |
|
363 | 364 |
|
364 | 365 |
def time_to_epoch(t): |
365 | 366 |
"""Convert time specified in a variety of forms into UNIX epoch time. |