简体   繁体   English

AWS boto3:看到证明客户端正在使用传输加速端点吗?

[英]AWS boto3: see proof that client is using transfer acceleration endpoint?

I'm trying to enable Transfer Acceleration for some AWS S3 buckets. 我正在尝试为某些AWS S3存储桶启用Transfer Acceleration。

I start up my client session: 我开始我的客户会议:

client = boto3.client(
        "s3",
        aws_access_key_id=environ.get("AWS_ACCESS_KEY_ID"),
        aws_secret_access_key=environ.get("AWS_SECRET_ACCESS_KEY")
    )

Then I turn Transfer Acceleration on through the S3 console, and have ensured it is enabled and turned on in the code as such: 然后,我通过S3控制台打开“传输加速”,并确保已启用并在代码中将其打开,如下所示:

response = client.put_bucket_accelerate_configuration(
    Bucket='string',
    AccelerateConfiguration={
        'Status': 'Enabled'
    }
)

and

response = client.get_bucket_accelerate_configuration(
    Bucket='string'
)

both snippets come straight from boto3 docs. 这两个代码片段都直接来自boto3文档。 I am able to upload to the bucket successfully later on in the code with: 稍后,我可以使用以下代码成功上传到存储桶:

client.upload_fileobj(data, environ.get("AWS_S3_BUCKET"), 'key')

I tried setting the endpoint_url param while starting the client session, but this just created a new folder (with my bucket title) inside my bucket. 在启动客户端会话时,我尝试设置了endpoint_url参数,但这只是在存储桶中创建了一个新文件夹(带有存储桶标题)。

It seems that boto3 is the only SDK that doesn't have some sort of "use transfer acceleration endpoint" flag. 看来boto3是唯一没有某种“使用传输加速端点”标志的SDK。 I know it is enabled on the bucket, and I have proof of that, but I have no proof that it is actually using the endpoint . 我知道它已在存储桶中启用,对此我有证明,但我没有证据表明它实际上在使用端点

I've tried going through client metadata, bucket metadata, and every other client method that returns any sort of data, and I can't find proof that it actually used the acceleration endpoint. 我尝试遍历客户端元数据,存储桶元数据以及返回任何类型数据的所有其他客户端方法,但找不到任何证据证明它实际上使用了加速端点。

Am I missing something? 我想念什么吗?

Connect to S3 accelerate endpoint with boto3 mentions using: 使用boto3提及连接到S3加速端点,方法是:

Config(s3={"use_accelerate_endpoint": True})

This parameter is listed in Config Reference — botocore documentation : 此参数在“ 配置参考” — botocore文档中列出:

s3 (dict) s3(dict)

use_accelerate_endpoint -- Refers to whether to use the S3 Accelerate endpoint. use_accelerate_endpoint指是否使用S3 Accelerate端点。 The value must be a boolean. 该值必须是布尔值。 If True, the client will use the S3 Accelerate endpoint. 如果为True,则客户端将使用S3 Accelerate端点。 If the S3 Accelerate endpoint is being used then the addressing style will always be virtual. 如果正在使用S3 Accelerate端点,则寻址方式将始终是虚拟的。

So try using: 因此,请尝试使用:

s3_client = boto3.client("s3", config=Config(s3={"use_accelerate_endpoint": True}))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM