Skip to content

Instantly share code, notes, and snippets.

@siakon89
Last active April 20, 2020 12:20
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 siakon89/bc7cd377c1277c8d9baf508bd23c3477 to your computer and use it in GitHub Desktop.
Save siakon89/bc7cd377c1277c8d9baf508bd23c3477 to your computer and use it in GitHub Desktop.
import boto3
from boto3.s3.transfer import TransferConfig
def upload_to_s3(file_name, bucket, key, region="us-east-1"):
# Multipart upload config
config = TransferConfig(
multipart_threshold=1024 * 25,
max_concurrency=10,
multipart_chunksize=1024 * 25,
use_threads=True,
)
s3 = boto3.client("s3", region_name=region)
# Upload file to S3
s3.upload_file(file_name, bucket, key, Config=config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment