diff --git a/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java b/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java index 3a80e824d3e0..53553912503a 100644 --- a/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java +++ b/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java @@ -59,6 +59,24 @@ public AmazonS3URI(final URI uri) { throw new IllegalArgumentException("Invalid S3 URI: no hostname: " + uri); } + + // s3://* + if (uri.getScheme().equalsIgnoreCase("s3")) { + this.region = null; + this.isPathStyle = false; + this.bucket = uri.getHost(); + + String path = uri.getPath(); + if (path.length() <= 1) { + // s3://bucket or s3://bucket/ + this.key = null; + } else { + // s3://bucket/key + // Remove the leading '/'. + this.key = uri.getPath().substring(1); + } + return; + } Matcher matcher = ENDPOINT_PATTERN.matcher(host); if (!matcher.find()) {