-
Notifications
You must be signed in to change notification settings - Fork 868
Description
Describe the bug
Attempt to instantiate an AmazonS3Uri object with an S3 Uri results in an exception
Expected Behavior
An AmazonS3Uri object should be created, with uri.Bucket
equals "my-bucket-name" and uri.Key
equals "file-name"
Current Behavior
Results in the following exception:
System.ArgumentException: Invalid S3 URI - hostname does not appear to be a valid S3 endpoint
Reproduction Steps
AmazonS3Uri uri = new AmazonS3Uri("s3://my-bucket-name/file-name");
Possible Solution
When running this exact line in Java it works fine. As can be seen in the sources of the Java SDK https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java
There is an If block at line 81 that handles the case where the Uri stars with "s3://" and if that condition is false they go to the regex check on the host in line 110. In the .NET SDK, it goes straight to that regex check, as can be seen in line 80 https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Services/S3/Custom/Util/AmazonS3Uri.cs
My suggestion is to add the same if block in the Java SDK
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.S3 3.7.3.17
Targeted .NET Platform
.NET 6
Operating System and version
Ubuntu