lambda_local_to_s3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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