Created
October 17, 2018 22:41
-
-
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)
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
#! /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