我正在使用Boto 3 python库,并希望连接到AWS CloudFront.我需要指定正确的AWS Profile(AWS Credentials),但查看官方文档,我认为无法指定它.
我正在使用代码初始化客户端:
client = boto3.client('cloudfront')
但是,这会导致它使用默认配置文件进行连接.我找不到一种方法可以指定要使用的配置文件.
因此,当我发出一个get()时,我所拥有的是一个字典,而dict的'Body'成员是一个"StreamingBody"类型,并且如何使用boto3将S3对象保存到文件中,我看到我怎么能从这里读取大块流,但我想知道是否有更简单的方法来做到这一点,la boto.
试过这个:
import boto3
from boto3.s3.transfer import TransferConfig, S3Transfer
path = "/temp/"
fileName = "bigFile.gz" # this happens to be a 5.9 Gig file
client = boto3.client('s3', region)
config = TransferConfig(
multipart_threshold=4*1024, # number of bytes
max_concurrency=10,
num_download_attempts=10,
)
transfer = S3Transfer(client, config)
transfer.upload_file(path+fileName, 'bucket', 'key')
Run Code Online (Sandbox Code Playgroud)
结果:s3上的5.9 gig文件.似乎不包含多个部分.
我找到了这个例子,但part没有定义.
import boto3
bucket = 'bucket'
path = "/temp/"
fileName = "bigFile.gz"
key = 'key'
s3 = boto3.client('s3')
# Initiate the multipart upload and send the part(s)
mpu = …Run Code Online (Sandbox Code Playgroud)