Skip to content

Instantly share code, notes, and snippets.

@milancermak
Created June 14, 2018 15:38
Show Gist options
  • Save milancermak/703dbdc1f75813fb27f9fdcfede28839 to your computer and use it in GitHub Desktop.
Save milancermak/703dbdc1f75813fb27f9fdcfede28839 to your computer and use it in GitHub Desktop.
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