Example to write a file to an S3 bucket:
from io import BytesIO
import boto3
aws_access_key_id = "your_aws_access_key_id"
aws_secret_access_key = "your_aws_secret_access_key"
region_name = "your_aws_region_name"
aws_bucket_name = "my-bucket-name"
s3_client = boto3.client(
's3',
aws_access_key_id = aws_access_key_id,
aws_secret_access_key= aws_secret_access_key,
region_name = region_name
)
s3_client.upload_fileobj(BytesIO(file_contents), aws_bucket_name, file_name)