Class AmazonS3File
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.amazons3.AmazonS3File
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,Serializable
- Direct Known Subclasses:
AmazonS3FileSink,AmazonS3FileSource
Base class for a file in Amazon S3, located by bucket name and path and accessed through an
AmazonS3FileSystem that other files may share. Its record and XML forms keep the name, bucket, path,
region, endpoint override and debug flag, but not credentials.- See Also:
-
Field Summary
FieldsFields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
ConstructorsConstructorDescriptionCreates a file with its own newAmazonS3FileSystem.AmazonS3File(AmazonS3FileSystem amazonS3FileSystem) Creates a file that uses the given file system, or a new one if it isnull. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThrows aDataExceptionif this file has noAmazonS3FileSystem.protected voidForgets the kept file size so the nextgetFileSize()looks it up in S3 again.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXmlElement(Element element) Returnsnull; the S3 object's content type is not looked up.AwsCredentialsProviderReturns the AWS SDK credentials provider that this file'sAmazonS3FileSystemuses when noCredentialsResolveris set.Returns the credentials resolver of this file'sAmazonS3FileSystemornullif there is none.longReturns the size in S3 in bytes, or -1 if the key is absent (other errors throw); a known size is kept until the bucket, path, or file system changes, a sink upload finishes, orrefreshFileSize()is called.getName()getPath()Returns the key of this file's object within its bucket.booleanisDebug()Indicates if this file'sAmazonS3FileSystemlogs multipart upload progress at debug level.booleanisLocal()longLooks the size up in S3 again, for an object that may have changed since its size was kept.protected voidretainFileSize(AmazonS3FileSystem fileSystem, String bucket, String key, Long size) Retainssizeonly if this file still points at the object it was looked up for.setAmazonS3FileSystem(AmazonS3FileSystem amazonS3FileSystem) setBasicAWSCredentials(String accessKey, String secretKey) Authenticates this file'sAmazonS3FileSystemwith the given access key and secret key, replacing its credentials provider, unless aCredentialsResolveris set, which takes precedence.setBucketName(String bucketName) setCredentialsProvider(AwsCredentialsProvider credentialsProvider) Sets the AWS SDK credentials provider that this file'sAmazonS3FileSystemuses when noCredentialsResolveris set.setCredentialsResolver(CredentialsResolver credentialsResolver) Sets the backend-neutral resolver supplying this file's credentials — resolved on each connection, so rotated secrets are picked up automatically.setDebug(boolean debug) Indicates if this file'sAmazonS3FileSystemlogs multipart upload progress at debug level.Sets the key of this file's object within its bucket.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.toXmlElement(Document document) Returns an element, created withdocument, describing this object; the default implementation throws aDataException.useProfileCredentialsProvider(String profileName) Authenticates this file'sAmazonS3FileSystemusing the named profile from the AWS profile files, unless aCredentialsResolveris set, which takes precedence.Methods inherited from class com.northconcepts.datapipeline.foundations.core.Bean
addExceptionProperties, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionProperties, exception, exception, exception
-
Field Details
-
amazonS3FileSystem
-
bucketName
-
path
-
-
Constructor Details
-
AmazonS3File
public AmazonS3File()Creates a file with its own newAmazonS3FileSystem. -
AmazonS3File
Creates a file that uses the given file system, or a new one if it isnull.
-
-
Method Details
-
assertValid
protected void assertValid()Throws aDataExceptionif this file has noAmazonS3FileSystem. -
getName
-
setName
-
getUrlPath
-
getFileSize
public long getFileSize()Returns the size in S3 in bytes, or -1 if the key is absent (other errors throw); a known size is kept until the bucket, path, or file system changes, a sink upload finishes, orrefreshFileSize()is called. -
refreshFileSize
public long refreshFileSize()Looks the size up in S3 again, for an object that may have changed since its size was kept. -
retainFileSize
Retainssizeonly if this file still points at the object it was looked up for. -
clearFileSize
protected void clearFileSize()Forgets the kept file size so the nextgetFileSize()looks it up in S3 again. -
getContentType
Returnsnull; the S3 object's content type is not looked up. -
getFileType
-
isLocal
public boolean isLocal() -
getCredentialsResolver
Returns the credentials resolver of this file'sAmazonS3FileSystemornullif there is none. -
setCredentialsResolver
Sets the backend-neutral resolver supplying this file's credentials — resolved on each connection, so rotated secrets are picked up automatically. Takes precedence oversetCredentialsProvider(AwsCredentialsProvider)and the default provider chain. -
getCredentialsProvider
public AwsCredentialsProvider getCredentialsProvider()Returns the AWS SDK credentials provider that this file'sAmazonS3FileSystemuses when noCredentialsResolveris set. -
setCredentialsProvider
Sets the AWS SDK credentials provider that this file'sAmazonS3FileSystemuses when noCredentialsResolveris set. -
useProfileCredentialsProvider
Authenticates this file'sAmazonS3FileSystemusing the named profile from the AWS profile files, unless aCredentialsResolveris set, which takes precedence. -
setBasicAWSCredentials
Authenticates this file'sAmazonS3FileSystemwith the given access key and secret key, replacing its credentials provider, unless aCredentialsResolveris set, which takes precedence. -
getAmazonS3FileSystem
-
setAmazonS3FileSystem
-
isDebug
public boolean isDebug()Indicates if this file'sAmazonS3FileSystemlogs multipart upload progress at debug level. -
setDebug
Indicates if this file'sAmazonS3FileSystemlogs multipart upload progress at debug level. -
getBucketName
-
setBucketName
-
getPath
Returns the key of this file's object within its bucket. -
setPath
Sets the key of this file's object within its bucket. -
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classBean
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classBean- Parameters:
source-- Returns:
- this instance.
-
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException. -
fromXmlElement
-