Skip to content

Commit

Permalink
/vsis3/: include region to build s3.{region}.amazonaws.com host name (f…
Browse files Browse the repository at this point in the history
…ixes OSGeo#9449)
  • Loading branch information
rouault committed Mar 12, 2024
1 parent a8846d1 commit c3faafa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autotest/gcore/vsis3.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_vsis3_no_sign_request(aws_test_config_as_config_options_or_credentials)
bucket = "noaa-goes16"
obj = "ABI-L1b-RadC/2022/001/00/OR_ABI-L1b-RadC-M6C01_G16_s20220010001173_e20220010003546_c20220010003587.nc"
vsis3_path = "/vsis3/" + bucket + "/" + obj
url = "https://" + bucket + ".s3.amazonaws.com/" + obj
url = "https://" + bucket + ".s3.us-east-1.amazonaws.com/" + obj

with gdaltest.config_options(
options, thread_local=False
Expand Down
6 changes: 5 additions & 1 deletion port/cpl_aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,12 @@ VSIS3HandleHelper *VSIS3HandleHelper::BuildFromURI(const char *pszURI,
osRegion = osDefaultRegion;
}

const std::string osEndpoint = VSIGetPathSpecificOption(
std::string osEndpoint = VSIGetPathSpecificOption(
osPathForOption.c_str(), "AWS_S3_ENDPOINT", "s3.amazonaws.com");
if (!osRegion.empty() && osEndpoint == "s3.amazonaws.com")
{
osEndpoint = "s3." + osRegion + ".amazonaws.com";
}
const std::string osRequestPayer = VSIGetPathSpecificOption(
osPathForOption.c_str(), "AWS_REQUEST_PAYER", "");
std::string osBucket;
Expand Down

0 comments on commit c3faafa

Please sign in to comment.