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

时间:2019-06-03 21:45:29

标签: python amazon-web-services amazon-s3 boto3

我正在尝试为某些AWS S3存储桶启用Transfer Acceleration。

我开始我的客户会话:

class item:
  pickup = False
  def __init__(self,name,description):
    self.name = name
    self.description = description
  def use(self,item2):
    print "I don't know how to do that" 

class hook(item):
  pickup = True
  def use(self,item2):      
    if item2.name == 'key':
      inventory.append(key)
      print "Despite your scrawny(yes i said scrawny) arms, you manage to pull the key out using your hook."
    else:
      print "you don't know what do with those things. Try something else"

然后,我通过S3控制台打开“传输加速”,并确保已在以下代码中将其启用并打开:

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

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

两个片段都直接来自boto3文档。稍后,我可以使用以下代码成功上传到存储桶中:

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

我在启动客户端会话时尝试设置client.upload_fileobj(data, environ.get("AWS_S3_BUCKET"), 'key') 参数,但这只是在存储桶中创建了一个新文件夹(带有存储桶标题)。

似乎boto3是唯一没有某种“使用传输加速端点”标志的SDK。我知道它已在存储桶中启用,对此我有证明,但我没有证据证明它实际上是 使用端点

我尝试遍历客户端元数据,存储桶元数据以及返回任何类型数据的所有其他客户端方法,但我找不到证明它确实使用了加速端点。

我想念什么吗?

1 个答案:

答案 0 :(得分:2)

Connect to S3 accelerate endpoint with boto3提到使用:

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

此参数在Config Reference — botocore documentation中列出:

  

s3(字典)

     

use_accelerate_endpoint-指是否使用S3 Accelerate端点。该值必须是布尔值。如果为True,则客户端将使用S3 Accelerate端点。如果正在使用S3 Accelerate端点,则寻址方式将始终是虚拟的。

所以尝试使用:

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