Skip to content

Instantly share code, notes, and snippets.

@astewart-twist
Created February 23, 2016 23:03
Show Gist options
  • Save astewart-twist/e835c6289d5017ee06a6 to your computer and use it in GitHub Desktop.
Save astewart-twist/e835c6289d5017ee06a6 to your computer and use it in GitHub Desktop.
flask s3 proxy
@route('/static/<path:path>')
def static_proxy(path):
conn = boto.s3.connection.S3Connection(ACCESS_KEY, SECRET_ACCESS_KEY)
bucket = conn.get_bucket(BUCKET_NAME, validate=False)
key = boto.s3.key.Key(bucket)
key.key = path
try:
key.open_read()
headers = dict(key.resp.getheaders())
return Response(key, headers=headers)
except boto.exception.S3ResponseError as e:
return flask.Response(e.body, status=e.status, headers=key.resp.getheaders())
@shubhams20
Copy link

How can i download , multiple files using this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment