I need to retrieve an public object URL directly after uploading a file, this to be able to store it in a database. This is my upload code:
s3 = boto3.res
Since 2010 you can use a virtual-hosted style S3 url, i.e. no need to mess with region specific urls:
url = f'https://{bucket}.s3.amazonaws.com/{key}'
Moreover, support for the path-style model (region specific urls) continues for buckets created on or before September 30, 2020. Buckets created after that date must be referenced using the virtual-hosted model.
See also this blog post.