I found the error, the s3_endpoint parameter with rake was wrong
, it should only include location, without the bucket name prefixed (the same as defined in admin—site settings—s3 endpoint):
DISCOURSE_S3_ENDPOINT="https://sfo2.digitaloceanspaces.com"
This topic can be closed.