CrossRegionS3Client without GetObjectLocation
Type: Feature
Is your feature request related to a problem? Please describe. I am accessing buckets via a role which is not a bucket owner, meaning that GetBucketLocation cannot work, and so the CrossRegionS3Client cannot work.
Describe the solution you'd like
The PermanentRedirect error includes the region that should be used; CrossRegionS3Client ought to be able to read the full error and get the region, thus avoiding the GetObjectLocation method altogether.
Alternatively, the PermanentRedirect also seems to include the region as a header, x-amz-bucket-region: us-west-2, which could be even easier to use.
Describe alternatives you've considered Trying to set the Region manually, but that defeats the point.
Additional context Example SDK error:
<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><Endpoint>mybucket.s3-us-west-2.amazonaws.com</Endpoint><Bucket>mybucket</Bucket><RequestId>...</RequestId><HostId>...</HostId></Error>
Headers:
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << HTTP/1.1 301 Moved Permanently
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << x-amz-bucket-region: us-west-2
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << x-amz-request-id: ...
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << x-amz-id-2: ...
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << Content-Type: application/xml
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << Transfer-Encoding: chunked
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << Date: Mon, 11 Jul 2022 18:02:48 GMT
2022-07-11 18:02:48,139 [main] DEBUG org.apache.http.headers - http-outgoing-5 << Server: AmazonS3