Helllo、私は非常に大きいS3バケットからすべてのファイルをダウンロードしようとしていますPythonのBoto3:エラーは、AWS S3
からファイルをダウンロードしようとします。私は、このことから
client = boto3.client('s3',
aws_access_key_id=tempCredentials.credentials.access_key,
aws_secret_access_key = tempCredentials.credentials.secret_key,
aws_session_token=tempCredentials.credentials.session_token)
:私はこのようなS3に接続していますよう
# This is going to go through and fill in the dictionary with keys
from the buckets as specified above
paginator = client.get_paginator("list_objects")
page_iterator = paginator.paginate(Bucket=bucket["Name"])
l = 0
# We are going to have an list that will hold all the keys
key_list = []
for i in page_iterator:
c = i["Contents"]
for j in c:
key_list.append(j["Key"])
for j in key_list:
download(bucket["Name"], j, "/Users/ahussain/Desktop/S3_Scrubber/" + file_name_helper(j), client)
場合には、私のダウンロード機能:
def download (bucket_name, key, path, client):
key_name = key
print("Dowloading %s..." % str(key))
client.download_file(bucket_name, key, path)
print("Download of %s complete!" % str(key))
return key_name
何が起こることは私が通過するということですバケットはうまくいっていて、適切な量の鍵をダウンロードしますが、しばらくするとプログラムの鍵ダウンロードが停止し、このエラーが表示されます。
botocore.exceptions.ClientError: An error occurred (400) when calling the HeadObject operation: Bad Request
私はこのS3にアクセスするためにMFAを使用しているのでセッションが切れていると思われますが、わかりません。誰もこのエラーに遭遇したことはありますか?
クライアントを構築するときに、バケットがある領域を指定できますか? 'client = boto3.client( 's3'、region_name = 'us-west-1'、....' – helloV