Last active
April 20, 2020 12:20
-
-
Save siakon89/bc7cd377c1277c8d9baf508bd23c3477 to your computer and use it in GitHub Desktop.
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
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