Python Boto3 update/overwrite object in S3 bucket

Viewed 17723

I can't find Python source code example to update/overwrite an object in an Amazon S3 Bucket.

Is this possible?

2 Answers

As mentioned in the other answer if you push the file with the same name it will overwrite it, just for completeness here is an actual implementation using boto3

import boto3 

s3 = boto3.resource(‘s3’)

try:
  s3.upload_file(file_path, bucket, key)
except ClientError as e:
  print("Error")
Related