import boto3
import os
S3_Object = boto3.client('s3', region_name='us-west-1' aws_access_key_id='access_key', aws_secret_access_key='secret_access_key')
s3 = boto3.resource('s3')
bucket = 'bucket_name'
#response = s3.Bucket(bucket).objects.all()
# If you want to search only specific path of bucket,
response = s3.Bucket(bucket).objects.filter(Prefix='folder_name')
path = '/tmp/logs'
if not os.path.exists(path):
os.makedirs(path)
for item in response:
filename = item.key.rsplit('/', 1)[-1]
if filename.endswith('.csv.gz'):
s3.Object(bucket, item.key).download_file(path + filename)
print("success")
Я получаю следующую ошибку raise NoCredentialsError
botocore.exceptions.NoCredentialsError: Unable to locate credentials
Поэтому я обновил .aws/config
и .aws/credentials
Вкл. .aws/config
:
[profile 1]
region=us-west-1
Вкл. .aws/credentials
:
aws_access_key_id='access_key'
aws_secret_access_key='secret_access_key'
Без удачи. Любая помощь очень ценится.