Get Cloudflare R2 Public URL after uploading file using boto3

826 Views Asked by At

Is there a way to upload a file to Cloudflare R2 storage using boto3 in Python, and get the public URL that it can be accessed at?

The files are being uploaded by doing

s3 = boto3.resource(
    "s3",
    endpoint_url=endpoint_url,
    aws_access_key_id=aws_access_key_id,
    aws_secret_access_key=secret_access_key,
)
bucket = s3.Bucket("my_bucket")
res = bucket.Object("foo.png").put(Body=f.read())

but the res reponse object returned does not appear to contain that looks like they can be used to construct the public URL.

Thanks!

0

There are 0 best solutions below