public class AmazonS3FileSystem extends FileSystem
| Modifier and Type | Class and Description |
|---|---|
static class |
AmazonS3FileSystem.CredentialsResolverBridge
Adapts the backend-neutral
CredentialsResolver seam to the AWS SDK's
AwsCredentialsProvider so resolved credentials flow through the native client natively. |
| Modifier and Type | Field and Description |
|---|---|
static long |
CREDENTIALS_EXPIRY_SKEW_MILLISECONDS
How long before a credentials snapshot's reported expiry the
AmazonS3FileSystem.CredentialsResolverBridge
re-resolves from the CredentialsResolver. |
static int |
DEFAULT_QUEUE_SIZE |
static int |
MINIMUM_PART_SIZE |
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEid, log, name, TIMESTAMP_FORMAT| Constructor and Description |
|---|
AmazonS3FileSystem()
Constructs an Amazon S3 file system instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the Amazon S3 connection.
|
void |
deleteFile(String bucket,
String key)
Deletes an S3 object from the specified bucket.
|
boolean |
exists(String bucket,
String key)
Checks if an S3 object exists in the specified bucket.
|
S3Client |
getClient() |
AwsCredentialsProvider |
getCredentialsProvider() |
String |
getEndpointOverride() |
String |
getRegion() |
boolean |
isDebug() |
List<S3Bucket> |
listBuckets()
Returns the buckets owned by the authenticated user.
|
S3ObjectListing |
listFolder(String bucket,
String folder)
Returns the objects in the specified bucket's folder.
|
S3ObjectListing |
listRootFolder(String bucket)
Returns the root objects in the specified bucket.
|
S3ObjectListing |
nextBatch(S3ObjectListing previousListing)
Returns the next set of paged objects.
|
void |
open()
Opens a connection to the Amazon S3 file system.
|
InputStream |
readFile(String bucket,
String filePath)
Reads the file in the S3 bucket.
|
AmazonS3FileSystem |
setBasicAWSCredentials(String accessKey,
String secretKey) |
AmazonS3FileSystem |
setClient(S3Client client) |
AmazonS3FileSystem |
setCredentialsProvider(AwsCredentialsProvider credentialsProvider) |
AmazonS3FileSystem |
setCredentialsResolver(CredentialsResolver credentialsResolver)
Sets the backend-neutral resolver supplying this file system's credentials (see
CredentialsResolver). |
AmazonS3FileSystem |
setDebug(boolean debug) |
AmazonS3FileSystem |
setEndpointOverride(String endpointOverride)
Overrides the S3 service endpoint (e.g.
|
AmazonS3FileSystem |
setRegion(String region)
Sets the AWS region (e.g.
|
AmazonS3FileSystem |
useProfileCredentialsProvider(String profileName)
Authenticates using the named profile from the AWS profile files (instead of the
default profile used by the default credentials provider chain).
|
OutputStream |
writeMultipartFile(String bucket,
String filePath) |
OutputStream |
writeMultipartFile(String bucket,
String filePath,
String contentType) |
credentialValue, getCredentialsResolver, getCurrentCredentials, refreshCredentials, resolveCredentialsaddElapsedtime, addExceptionProperties, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getNestedEndpoint, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getRootEndpoint, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription, toStringpublic static final int MINIMUM_PART_SIZE
public static final int DEFAULT_QUEUE_SIZE
public static final long CREDENTIALS_EXPIRY_SKEW_MILLISECONDS
AmazonS3FileSystem.CredentialsResolverBridge
re-resolves from the CredentialsResolver.public AmazonS3FileSystem()
public AmazonS3FileSystem setCredentialsResolver(CredentialsResolver credentialsResolver)
CredentialsResolver). Resolved at open() — never at construction — so rotated
secrets are picked up on the next connection; expiring credentials (for example STS session
tokens) are additionally re-resolved mid-session when they report expiry within
CREDENTIALS_EXPIRY_SKEW_MILLISECONDS.
When a resolver is set, it takes precedence over
setCredentialsProvider(AwsCredentialsProvider) and the default provider chain.
setCredentialsResolver in class FileSystempublic AwsCredentialsProvider getCredentialsProvider()
public AmazonS3FileSystem setCredentialsProvider(AwsCredentialsProvider credentialsProvider)
public AmazonS3FileSystem useProfileCredentialsProvider(String profileName)
public AmazonS3FileSystem setBasicAWSCredentials(String accessKey, String secretKey)
public String getRegion()
public AmazonS3FileSystem setRegion(String region)
"us-east-1"). When unset, the region is resolved
from the default region provider chain, falling back to us-east-1.public String getEndpointOverride()
public AmazonS3FileSystem setEndpointOverride(String endpointOverride)
setRegion(String) when signing requires it.public boolean isDebug()
public AmazonS3FileSystem setDebug(boolean debug)
public void open()
throws DataException
Credentials are chosen in this order: the CredentialsResolver (if set), then the
configured AwsCredentialsProvider (which defaults to the standard provider chain).
open in class EndpointDataExceptionpublic void close()
throws DataException
open() are closed and released so
the next open() rebuilds one — picking up rotated credentials; clients supplied
through setClient(S3Client) are left untouched — their lifecycle belongs to the
caller — and remain usable if this file system is reopened.close in class FileSystemDataExceptionpublic S3Client getClient()
public AmazonS3FileSystem setClient(S3Client client)
public InputStream readFile(String bucket, String filePath)
public boolean exists(String bucket, String key) throws DataException
bucket - the name of the S3 bucketkey - the key (path) of the S3 objectDataException - if bucket or key is empty, or if an error occurs while checking existencepublic void deleteFile(String bucket, String key) throws DataException
bucket - the name of the S3 bucketkey - the key (path) of the S3 object to deleteDataException - if bucket or key is empty, or if an error occurs while deleting the objectpublic OutputStream writeMultipartFile(String bucket, String filePath)
public OutputStream writeMultipartFile(String bucket, String filePath, String contentType)
public List<S3Bucket> listBuckets() throws Throwable
Throwablepublic S3ObjectListing listRootFolder(String bucket) throws Throwable
Throwablepublic S3ObjectListing listFolder(String bucket, String folder) throws Throwable
Throwablepublic S3ObjectListing nextBatch(S3ObjectListing previousListing) throws Throwable
ThrowableCopyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.