Spaces-API PHP only works with us-east-1: SpaceDoesntExistException in other regions

With SociallyDev/Spaces-API v3.5.0, connecting to any DigitalOcean Spaces region except us-east-1 failed with SpaceDoesntExistException even though the space existed: e.g. a bucket in sfo2 threw Space 'assets-storage' does not exist. The constructor accepts a region argument, but the Spaces class hardcoded us-east-1 when instantiating the underlying S3 client, so the endpoint URL and the client region disagreed and the bucket lookup ran against the wrong region.

The region passed to the Spaces constructor was used for the endpoint URL but the S3 client itself was hardcoded to us-east-1, so non-us-east-1 spaces could never be found. The maintainer acknowledged the bug and invited a PR. Until it is fixed upstream, patch the hardcoded region in SpacesAPI/Spaces.php (or the S3 client instantiation it performs) to your region, e.g. sfo2, and construct with new Spaces($key, $secret, $region) using a space name that exists in that region. The reporter confirmed this fixed their sfo2 bucket access.

Source: https://github.com/SociallyDev/Spaces-API/issues/85