in files/default/rgw_s3_api.py [0:0]
def object_url(bucket, name, signed_duration=0, query_auth=False, force_http=False, verbose=False):
"""
:param bucket:
:param name:
:param signed_duration:
:param query_auth:
:param force_http: default is False so that the port is included if the port is not 80
:param verbose:
:return: url
"""
if not bucket or not name:
if verbose:
print('Bucket and/or object name is not valid.')
return None
url = None
try:
if signed_duration < 0:
signed_duration = 0
if signed_duration > 0 and query_auth is False:
query_auth = True
key_object = bucket.get_key(name)
# If the signed_duration is > than 0 then assume a signed url with signed_duration the amount of time the url
# is valid.
url = key_object.generate_url(signed_duration, query_auth=query_auth, force_http=force_http)
if url and verbose:
print('Generated %s' % url)
except BaseException, e:
print(e.message)
return url