Skip to content

Instantly share code, notes, and snippets.

@wthorp
Created May 27, 2022 12:16
Show Gist options
  • Save wthorp/6ca45e70ea4de7b8a50787322c15c381 to your computer and use it in GitHub Desktop.
Save wthorp/6ca45e70ea4de7b8a50787322c15c381 to your computer and use it in GitHub Desktop.
Force S3 CopyObject over PutPartCopy
import boto3
import os
from boto3.s3.transfer import TransferConfig
# Set the desired multipart threshold to an arbitrarily large value.
EB = 1024 ** 6
config = TransferConfig(multipart_threshold=EB)
session = boto3.session.Session()
s3_client = session.client(
service_name='s3',
aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'),
aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'),
endpoint_url=os.getenv('AWS_ENDPOINT'),
)
copy_source = {
'Bucket': 'billtest2',
'Key': 'big4.mp4'
}
print(s3_client.copy(copy_source, 'billtest', 'big4.mp4', Config=config))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment