s3_file
s3_file copied to clipboard
Handle 307s from S3
When S3 responds with a 307, the s3_file
resource errors out with an error like
[2016-06-21T17:31:53+00:00] ERROR: 307 Temporary Redirect
But 307s are an expected response from S3 and entirely recoverable, as described in the docs:
Temporary Request Redirection
A temporary redirect is a type of error response that signals to the requester that he should resend his request to a different endpoint.
Due to the distributed nature of Amazon S3, requests can be temporarily routed to the wrong facility. This is most likely to occur immediately after buckets are created or deleted. For example, if you create a new bucket and immediately make a request to the bucket, you might receive a temporary redirect, depending on the location constraint of the bucket. If you created the bucket in the US East (N. Virginia) region (s3.amazonaws.com endpoint) you will not see the redirect because this is also the default endpoint. However, if bucket is created in any other region, any requests for the bucket will go to the default endpoint while the bucket's DNS entry is propagated. The default endpoint will redirect the request to the correct endpoint with a HTTP 302 response.
Temporary redirects contain a URI to the correct facility which you can use to immediately resend the request.