# -*- coding: utf-8 -*- import boto3 from boto3.s3.transfer import TransferConfig # from s3transfer.manager import TransferConfig access_key = "xxx" secret_key = "xxx" cli = boto3.client( 's3', aws_access_key_id=access_key, aws_secret_access_key=secret_key, endpoint_url='http://ss.bscstorage.com' ) config = TransferConfig( multipart_threshold=30 * 1024 * 1024, multipart_chunksize=8 * 1024 * 1024, max_concurrency=10, ) # 50MB/s # 單位是byte config.max_bandwidth = 50 * 1024 * 1024 resp = cli.upload_file( '/tmp/VSCode-darwin-stable.zip', 'test', 'test-key-xx2', ExtraArgs={ 'ContentType': 'text/plain', # 請替換爲合適的文件類型 'ACL': 'private', }, Config=config )