Skip to content

Instantly share code, notes, and snippets.

@gabrielrojasnyc
Last active October 24, 2017 03:48
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 gabrielrojasnyc/7675b9dac8b98db8c3c6c5b920933163 to your computer and use it in GitHub Desktop.
Save gabrielrojasnyc/7675b9dac8b98db8c3c6c5b920933163 to your computer and use it in GitHub Desktop.
lambda_local_to_s3.py
import time
import requests
import smart_open
import logging
print('Loading function')
def lambda_handler(event, context):
start_time = time.time()
uri = 'http://ipv4.download.thinkbroadband.com/100MB.zip'
response = requests.get(uri, stream=True)
with smart_open.smart_open('s3://mylocalbucket/100.zip', 'wb') as file_gabe:
for chunk in response.iter_content(chunk_size=8096):
if chunk:
file_gabe.write(chunk)
else:
logging.info('File was transfer')
print("time {}".format((time.time() - start_time)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment