Class S3Uri

java.lang.Object
software.amazon.awssdk.services.s3.S3Uri
All Implemented Interfaces:
ToCopyableBuilder<S3Uri.Builder,S3Uri>

@Immutable public final class S3Uri extends Object implements ToCopyableBuilder<S3Uri.Builder,S3Uri>
Object that represents a parsed S3 URI. Can be used to easily retrieve the bucket, key, region, style, and query parameters of the URI. Only path-style and virtual-hosted-style URI parsing is supported, including CLI-style URIs, e.g., "s3://bucket/key". AccessPoints and Outposts URI parsing is not supported. If you work with object keys and/or query parameters with special characters, they must be URL-encoded, e.g., replace " " with "%20". If you work with virtual-hosted-style URIs with bucket names that contain a dot, i.e., ".", the dot must not be URL-encoded. Encoded buckets, keys, and query parameters will be returned decoded.
  • Method Details

    • builder

      public static S3Uri.Builder builder()
    • toBuilder

      public S3Uri.Builder toBuilder()
      Description copied from interface: ToCopyableBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToCopyableBuilder<S3Uri.Builder,S3Uri>
      Returns:
      a builder for type T
    • uri

      public URI uri()
      Returns the original URI that was used to instantiate the S3Uri
    • bucket

      public Optional<String> bucket()
      Returns the bucket specified in the URI. Returns an empty optional if no bucket is specified.
    • key

      public Optional<String> key()
      Returns the key specified in the URI. Returns an empty optional if no key is specified.
    • region

      public Optional<Region> region()
      Returns the region specified in the URI. Returns an empty optional if no region is specified, i.e., global endpoint.
    • isPathStyle

      public boolean isPathStyle()
      Returns true if the URI is path-style, false if the URI is virtual-hosted style.
    • rawQueryParameters

      public Map<String,List<String>> rawQueryParameters()
      Returns a map of the query parameters specified in the URI. Returns an empty map if no queries are specified.
    • firstMatchingRawQueryParameters

      public List<String> firstMatchingRawQueryParameters(String key)
      Returns the list of values for a specified query parameter. A empty list is returned if the URI does not contain the specified query parameter.
    • firstMatchingRawQueryParameter

      public Optional<String> firstMatchingRawQueryParameter(String key)
      Returns the value for the specified query parameter. If there are multiple values for the query parameter, the first value is returned. An empty optional is returned if the URI does not contain the specified query parameter.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object