Skip to content

Instantly share code, notes, and snippets.

@revolutionisme
Forked from ghelobytes/convert.py
Created July 4, 2023 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revolutionisme/05ca22912f32075afec61e2c8d2eb605 to your computer and use it in GitHub Desktop.
Save revolutionisme/05ca22912f32075afec61e2c8d2eb605 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