Boto3 using Cloudflare R2, resigned urls SignatureDoesNotMatch

When using boto3 to upload a file to an R2 Bucket using a presigned url generated like this:

s3_client = boto3.client("s3", endpoint_url=current_app.config.get("S3_ENDPOINT"), aws_access_key_id=current_app.config.get("AWS_ACCESS_KEY_ID"), aws_secret_access_key=current_app.config.get("AWS_SECRET_ACCESS_KEY"), config=boto3.session.Config(signature_version='s3v4'), region_name="eeur")
        presigned_url = s3_client.generate_presigned_url(
            'get_object',
            Params={'Bucket': Setting.get("BUCKET_NAME").get_value(), 'Key': s3_object_key},
            ExpiresIn=URL_EXPIRATION_SECONDS
        )

And then trying to upload a File it Errors, when I try to post to the same signed url using Postman the Error is this:

<Error>
<script/>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your secret access key and signing method. </Message>
</Error>
1 Like