Skip to content

Instantly share code, notes, and snippets.

@gabrielrojasnyc
Last active October 24, 2017 03:48
Embed
What would you like to do?
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