Skip to content

Instantly share code, notes, and snippets.

@TonyFNZ
Created October 17, 2018 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyFNZ/9e888528526e73f8d011690de73cfb6b to your computer and use it in GitHub Desktop.
Save TonyFNZ/9e888528526e73f8d011690de73cfb6b to your computer and use it in GitHub Desktop.
This script will download a file from a URL and stream it directly into AWS S3 without persisting the file to local disk. File is streamed as it arrives, so memory usage is low (typically <100MB)
#! /bin/python
# This script will download a file from a URL and stream it directly
# into AWS S3 without persisting the file to local disk.
# File is streamed as it arrives, so memory usage is low (typically <100MB)
import boto3, urllib2
source_url = 'http://<Your URL Here>'
target_bucket = '<Target S3 Bucket Here>'
target_key = '<Target S3 Filename/Key>'
S3 = boto3.client('s3')
file_data = urllib2.urlopen( source )
S3.upload_fileobj(file_data, target_bucket, target_key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment