Skip to content

Commit

Permalink
Add s3://bucket/key support for AmazonS3URI
Browse files Browse the repository at this point in the history
  • Loading branch information
rch850 committed Jul 11, 2014
1 parent aef1849 commit 1d8722f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/com/amazonaws/services/s3/AmazonS3URI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 1d8722f

Please sign in to comment.