Я пытаюсь загрузить файл изображения в s3, используя boto3 на Rpi, используя aws iot sdk, но он выдаст сообщение об ошибке
boto3.exceptions.UnknownAPIVersionError: Ресурс 's3' не является версией API: сопровождается моим секретным ключом доступа
BUCKET = '' # replace with your own unique bucket name
location = {'LocationConstraint': 'us-east-2'}
def uploadToS3(file_path,file_name, bucket_name,location):
s3 = boto3.resource('s3',access_key_id,secret_access_key) # Create an S3 resource
exists = True
try:
s3.meta.client.head_bucket(Bucket=bucket_name)
except botocore.exceptions.ClientError as e:
error_code = int(e.response['Error']['Code'])
if error_code == 404:
exists = False
if exists == False:
s3.create_bucket(Bucket=bucket_name,CreateBucketConfiguration=location)
# Upload the file
full_path = file_path + "/" + file_name
s3.Object(bucket_name, file_name).put(Body=open(full_path, 'rb'))
print("File uploaded")
функция вызывается с помощью
uploadToS3(file_path,file_name, BUCKET,location)