@Immutable public final class S3Utilities extends Object
1) Directly using the builder() method. You have to manually specify the configuration params like region,
s3Configuration on the builder.
S3Utilities utilities = S3Utilities.builder().region(Region.US_WEST_2).build()
GetUrlRequest request = GetUrlRequest.builder().bucket("foo-bucket").key("key-without-spaces").build();
URL url = utilities.getUrl(request);
2) Using the low-level client S3Client.utilities() method. This is recommended as SDK will use the same
configuration from the S3Client object to create the S3Utilities object.
S3Client s3client = S3Client.create();
S3Utilities utilities = s3client.utilities();
GetUrlRequest request = GetUrlRequest.builder().bucket("foo-bucket").key("key-without-spaces").build();
URL url = utilities.getUrl(request);
Note: This class does not make network calls.| Modifier and Type | Class and Description |
|---|---|
static class |
S3Utilities.Builder
Builder class to construct
S3Utilities object |
| Modifier and Type | Method and Description |
|---|---|
static S3Utilities.Builder |
builder()
Creates a builder for
S3Utilities. |
URL |
getUrl(Consumer<GetUrlRequest.Builder> getUrlRequest)
Returns the URL for an object stored in Amazon S3.
|
URL |
getUrl(GetUrlRequest getUrlRequest)
Returns the URL for an object stored in Amazon S3.
|
public static S3Utilities.Builder builder()
S3Utilities.public URL getUrl(Consumer<GetUrlRequest.Builder> getUrlRequest)
If same configuration options are set on both #GetUrlRequest and #S3Utilities objects (for example: region), the configuration set on the #GetUrlRequest takes precedence.
This is a convenience which creates an instance of the GetUrlRequest.Builder avoiding the need to
create one manually via GetUrlRequest.builder()
getUrlRequest - A Consumer that will call methods on GetUrlRequest.Builder to create a request.SdkException - Generated Url is malformedpublic URL getUrl(GetUrlRequest getUrlRequest)
If same configuration options are set on both #GetUrlRequest and #S3Utilities objects (for example: region), the configuration set on the #GetUrlRequest takes precedence.
getUrlRequest - request to construct urlSdkException - Generated Url is malformedCopyright © 2021. All rights reserved.