Skip to content

Instantly share code, notes, and snippets.

@ghelobytes
Created March 21, 2019 02:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ghelobytes/6af6931942e107cc6a3218a8637e7d56 to your computer and use it in GitHub Desktop.
Save ghelobytes/6af6931942e107cc6a3218a8637e7d56 to your computer and use it in GitHub Desktop.
Convert s3 url to http url
def s3_to_http(url):
if url.startswith('s3://'):
s3_path = url
bucket = s3_path[5:].split('/')[0]
object_name = '/'.join(s3_path[5:].split('/')[1:])
return 'https://s3.amazonaws.com/{0}/{1}'.format(bucket, object_name)
else:
return url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment