software.amazon.nio.spi.s3.util.S3FileSystemInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-java-nio-spi-for-s3 Show documentation
Show all versions of aws-java-nio-spi-for-s3 Show documentation
A Java NIO.2 service provider for S3, allowing Java NIO operations to be performed on paths using the `s3` scheme. This
package implements the service provider interface (SPI) defined for Java NIO.2 in JDK 1.7 providing "plug-in" non-blocking
access to S3 objects for Java applications using Java NIO.2 for file access.
The newest version!
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package software.amazon.nio.spi.s3.util;
import java.net.URI;
import software.amazon.awssdk.services.s3.internal.BucketUtils;
/**
* Populates fields with information extracted by the S3 URI provided. This
* implementation is for standard AWS buckets as described in section
* "Accessing a bucket using S3://"
* here
*
* It also computes the file system key that can be used to identify a runtime
* instance of a S3FileSystem (for caching purposes for example). In this
* implementation the key is the bucket name (which is unique in the AWS S3
* namespace).
*/
public class S3FileSystemInfo {
protected String key;
protected String endpoint;
protected String bucket;
protected String accessKey;
protected String accessSecret;
protected S3FileSystemInfo() {
}
/**
* Creates a new instance and populates it with key and bucket. The name of
* the bucket must follow AWS S3
* bucket naming rules)
*
* @param uri a S3 URI
* @throws IllegalArgumentException if URI contains invalid components
* (e.g. an invalid bucket name)
*/
public S3FileSystemInfo(URI uri) throws IllegalArgumentException {
if (uri == null) {
throw new IllegalArgumentException("uri can not be null");
}
key = uri.getAuthority();
bucket = uri.getAuthority();
BucketUtils.isValidDnsBucketName(bucket, true);
}
public String key() {
return key;
}
public String endpoint() {
return endpoint;
}
public String bucket() {
return bucket;
}
public String accessKey() {
return accessKey;
}
public String accessSecret() {
return accessSecret;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy