Skip to content

Commit

Permalink
feat(s3): Use us-east-1 while head bucket returns 403 without X-Amz-B…
Browse files Browse the repository at this point in the history
…ucket-Region (#2677)

* s3 head with no X-Amz-Bucket-Region , using us-east-1 region as default

* fix cargo fmt
  • Loading branch information
john8628 authored Jul 20, 2023
1 parent 177e243 commit ce89210
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,15 @@ impl S3Builder {
);

match res.status() {
StatusCode::OK | StatusCode::FORBIDDEN | StatusCode::MOVED_PERMANENTLY => {
StatusCode::OK | StatusCode::MOVED_PERMANENTLY => {
let region = res.headers().get("x-amz-bucket-region")?;
if let Ok(regin) = region.to_str() {
Some(regin.to_string())
} else {
None
}
}
StatusCode::FORBIDDEN => Some("us-east-1".to_string()),
// Unexpected status code
_ => None,
}
Expand Down

0 comments on commit ce89210

Please sign in to comment.