Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Streaming upload of a file directly to S3 in AWS Lambda
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
You can’t perform that action at this time.