Created
June 14, 2018 15:38
-
-
Save milancermak/703dbdc1f75813fb27f9fdcfede28839 to your computer and use it in GitHub Desktop.
Streaming upload of a file directly to S3 in AWS Lambda
This file contains hidden or 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
from botocore.vendored import requests | |
import boto3 | |
def main(event, context): | |
s3 = boto3.resource('s3') | |
bucket = s3.Bucket('mybucket') | |
destination = bucket.Object('path/to/destination') | |
url = 'https://foobar.com' | |
with requests.get(url, stream=True) as response: | |
destination.upload_fileobj(response.raw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment