Class AmazonS3FileSystem
java.lang.Object
org.frankframework.filesystem.AbstractFileSystem<S3FileRef>
org.frankframework.filesystem.AmazonS3FileSystem
- All Implemented Interfaces:
AutoCloseable, HasPhysicalDestination, IBasicFileSystem<S3FileRef>, ISupportsCustomFileAttributes<S3FileRef>, IWritableFileSystem<S3FileRef>
@DestinationType(FILE_SYSTEM)
public class AmazonS3FileSystem
extends AbstractFileSystem<S3FileRef>
implements IWritableFileSystem<S3FileRef>, ISupportsCustomFileAttributes<S3FileRef>
-
Field Summary
Fields inherited from interface ISupportsCustomFileAttributes
FILE_ATTRIBUTE_PARAM_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendFile(@NonNull S3FileRef file, @Nullable InputStream content) voidclose()voidcopyFile(@NonNull S3FileRef s3Object, @NonNull String destinationFolder, boolean createFolder, @NonNull Map<String, String> customFileAttributes) Copies the file to another folder, adding the given custom file attributes to the file in the destination folder.Copies the file to another folder.voidcreateFile(@NonNull S3FileRef f, @Nullable InputStream content) Create a file with the given content inputstreamvoidcreateFile(@NonNull S3FileRef f, @Nullable InputStream content, @NonNull Map<String, String> customFileAttributes) Creates a file with the given custom file attributes.voidcreateFolder(String folder) software.amazon.awssdk.services.s3.S3ClientvoidbooleanbooleanfolderExists(String folder) @NonNull StringgetCanonicalName(@NonNull S3FileRef f) protected software.amazon.awssdk.auth.credentials.AwsCredentialsProvider@Nullable StringgetCustomFileAttribute(@NonNull S3FileRef file, @NonNull String name) Gets the value of the given custom file attribute on the given file.longprotected software.amazon.awssdk.http.apache.ApacheHttpClient.BuilderGet a string representation of an identification of a file.@Nullable StringgetParentFolder(@NonNull S3FileRef f) boolean@NonNull DirectoryStream<S3FileRef> list(S3FileRef folder, @NonNull TypeFilter filter) moveFile(@NonNull S3FileRef f, @NonNull String destinationFolder, boolean createFolder, @NonNull Map<String, String> customFileAttributes) Moves the file to another folder, adding the given custom file attributes to the file in the destination folder.Moves the file to another folder.voidopen()If you retrieve an S3Object, you should close this input stream as soon as possible, because the object content is not buffered in memory and streams directly from Amazon S3.voidremoveFolder(String folder, boolean removeNonEmptyFolder) renameFile(@NonNull S3FileRef source, @NonNull S3FileRef destination) Renames the file to a new name, possibly in another folder.renameFile(@NonNull S3FileRef source, @NonNull S3FileRef destination, @NonNull Map<String, String> customFileAttributes) Renames the file to a new name, possibly in another folder.voidsetAccessKey(String accessKey) Access key to access to the AWS resources owned by the accountvoidsetAuthAlias(String authAlias) Alias used to obtain AWS credentialsvoidsetBucketName(String bucketName) Name of the bucket to access.voidsetChunkedEncodingDisabled(boolean chunkedEncodingDisabled) Setting this flag will result in disabling chunked encoding for all requests.voidsetClientRegion(String clientRegion) Name of the AWS region that the client is using.voidsetForceGlobalBucketAccessEnabled(boolean forceGlobalBucketAccessEnabled) Option to enable or disable the usage of multi-region access point ARNs.voidsetMaxConnections(int maxConnections) Maximum concurrent connections towards S3voidsetProxyHost(String proxyHost) Proxy hostvoidsetProxyPort(Integer proxyPort) Proxy portvoidsetSecretKey(String secretKey) Secret key to access to the AWS resources owned by the accountvoidsetServiceEndpoint(String serviceEndpoint) The S3 service endpoint, either with or without the protocol.voidsetStorageClass(S3StorageClass storageClass) Set the desired storage class for the S3 object when action is move,copy or write.@NonNull S3FileRefCreates a local S3Object pointer, not representative with what is stored in the S3 Bucket.@NonNull S3FileRefCreates a reference to a file.Methods inherited from class AbstractFileSystem
getMaxNumberOfMessagesToList, isOpen, setMaxNumberOfMessagesToListMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IBasicFileSystem
getCanonicalNameOrErrorMessage, isOpen, listMethods inherited from interface ISupportsCustomFileAttributes
getCustomFileAttributes, hasCustomFileAttributes
-
Constructor Details
-
AmazonS3FileSystem
public AmazonS3FileSystem()
-
-
Method Details
-
configure
- Specified by:
configurein interfaceIBasicFileSystem<S3FileRef>- Throws:
ConfigurationException
-
open
- Specified by:
openin interfaceIBasicFileSystem<S3FileRef>- Overrides:
openin classAbstractFileSystem<S3FileRef>- Throws:
FileSystemException
-
getCredentialProvider
protected software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCredentialProvider() -
createS3Client
public software.amazon.awssdk.services.s3.S3Client createS3Client() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIBasicFileSystem<S3FileRef>- Overrides:
closein classAbstractFileSystem<S3FileRef>- Throws:
FileSystemException
-
toFile
Creates a local S3Object pointer, not representative with what is stored in the S3 Bucket. This method may be used to upload a file to S3.- Specified by:
toFilein interfaceIBasicFileSystem<S3FileRef>
-
toFile
Description copied from interface:IBasicFileSystemCreates a reference to a file. If filename is not absolute, it will be created in 'defaultFolder'.- Specified by:
toFilein interfaceIBasicFileSystem<S3FileRef>
-
list
public @NonNull DirectoryStream<S3FileRef> list(S3FileRef folder, @NonNull TypeFilter filter) throws FileSystemException - Specified by:
listin interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
exists
- Specified by:
existsin interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
isFolder
- Specified by:
isFolderin interfaceIBasicFileSystem<S3FileRef>
-
createFile
public void createFile(@NonNull S3FileRef f, @Nullable InputStream content) throws FileSystemException, IOException Description copied from interface:IWritableFileSystemCreate a file with the given content inputstream- Specified by:
createFilein interfaceIWritableFileSystem<S3FileRef>- Parameters:
f- FileSystem file referencecontent- to write or NULL. When NULL existing files should be overwritten, and new files should be created.- Throws:
FileSystemExceptionIOException
-
createFile
public void createFile(@NonNull S3FileRef f, @Nullable InputStream content, @NonNull Map<String, String> customFileAttributes) throws FileSystemException, IOExceptionDescription copied from interface:ISupportsCustomFileAttributesCreates a file with the given custom file attributes.- Specified by:
createFilein interfaceISupportsCustomFileAttributes<S3FileRef>- Parameters:
f- File to createcontent- Contents of the filecustomFileAttributes- Custom file attributes to apply to the file- Throws:
FileSystemExceptionIOException
-
appendFile
- Specified by:
appendFilein interfaceIWritableFileSystem<S3FileRef>
-
readFile
If you retrieve an S3Object, you should close this input stream as soon as possible, because the object content is not buffered in memory and streams directly from Amazon S3. Failure to close this stream can cause the request pool to become blocked.- Specified by:
readFilein interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
deleteFile
- Specified by:
deleteFilein interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
folderExists
- Specified by:
folderExistsin interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
createFolder
- Specified by:
createFolderin interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
removeFolder
- Specified by:
removeFolderin interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
renameFile
public S3FileRef renameFile(@NonNull S3FileRef source, @NonNull S3FileRef destination) throws FileSystemException Description copied from interface:IWritableFileSystemRenames the file to a new name, possibly in another folder. Does not need to check for the existence of the source or non-existence of the destination.- Specified by:
renameFilein interfaceIWritableFileSystem<S3FileRef>- Throws:
FileSystemException
-
renameFile
public S3FileRef renameFile(@NonNull S3FileRef source, @NonNull S3FileRef destination, @NonNull Map<String, String> customFileAttributes) throws FileSystemExceptionDescription copied from interface:ISupportsCustomFileAttributesRenames the file to a new name, possibly in another folder. Does not need to check for the existence of the source or non-existence of the destination.- Specified by:
renameFilein interfaceISupportsCustomFileAttributes<S3FileRef>- Throws:
FileSystemException
-
copyFile
public S3FileRef copyFile(S3FileRef s3Object, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystemCopies the file to another folder. Does not need to check for existence of the source or non-existence of the destination. Returns the copied file, or null if no file was copied or there is no reference to the copied file.- Specified by:
copyFilein interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
copyFile
public S3FileRef copyFile(@NonNull S3FileRef s3Object, @NonNull String destinationFolder, boolean createFolder, @NonNull Map<String, String> customFileAttributes) throws FileSystemExceptionDescription copied from interface:ISupportsCustomFileAttributesCopies the file to another folder, adding the given custom file attributes to the file in the destination folder. Does not need to check for existence of the source or non-existence of the destination. Returns the copied file, or null if no file was copied or there is no reference to the copied file.- Specified by:
copyFilein interfaceISupportsCustomFileAttributes<S3FileRef>- Throws:
FileSystemException
-
moveFile
public S3FileRef moveFile(S3FileRef f, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystemMoves the file to another folder. Does not need to check for existence of the source or non-existence of the destination. Returns the moved file, or null if no file was moved or there is no reference to the moved file.- Specified by:
moveFilein interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
moveFile
public S3FileRef moveFile(@NonNull S3FileRef f, @NonNull String destinationFolder, boolean createFolder, @NonNull Map<String, String> customFileAttributes) throws FileSystemExceptionDescription copied from interface:ISupportsCustomFileAttributesMoves the file to another folder, adding the given custom file attributes to the file in the destination folder. Does not need to check for existence of the source or non-existence of the destination. Returns the moved file, or null if no file was moved or there is no reference to the moved file.- Specified by:
moveFilein interfaceISupportsCustomFileAttributes<S3FileRef>- Throws:
FileSystemException
-
getAdditionalFileProperties
- Specified by:
getAdditionalFilePropertiesin interfaceIBasicFileSystem<S3FileRef>
-
getName
Description copied from interface:IBasicFileSystemGet a string representation of an identification of a file. Must pair up with the implementation ofIBasicFileSystem.toFile(String). Can reflect name a file has in its folder, is not expected to be unique over folders.- Specified by:
getNamein interfaceIBasicFileSystem<S3FileRef>
-
getParentFolder
- Specified by:
getParentFolderin interfaceIBasicFileSystem<S3FileRef>
-
getCanonicalName
- Specified by:
getCanonicalNamein interfaceIBasicFileSystem<S3FileRef>
-
getFileSize
- Specified by:
getFileSizein interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
getModificationTime
- Specified by:
getModificationTimein interfaceIBasicFileSystem<S3FileRef>- Throws:
FileSystemException
-
getHttpClientBuilder
protected software.amazon.awssdk.http.apache.ApacheHttpClient.Builder getHttpClientBuilder() -
getCustomFileAttribute
Description copied from interface:ISupportsCustomFileAttributesGets the value of the given custom file attribute on the given file. If the attribute does not exist,nullis returned.- Specified by:
getCustomFileAttributein interfaceISupportsCustomFileAttributes<S3FileRef>- Parameters:
file- File object for which to get the extended attribute. Must not benull.name- Name of the extended attribute to get. Must not benull.- Returns:
- Value of the extended attribute or
nullif the attribute does not exist.
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-
setAccessKey
Access key to access to the AWS resources owned by the account -
setSecretKey
Secret key to access to the AWS resources owned by the account -
setAuthAlias
Alias used to obtain AWS credentials -
setChunkedEncodingDisabled
public void setChunkedEncodingDisabled(boolean chunkedEncodingDisabled) Setting this flag will result in disabling chunked encoding for all requests.- Default value
- false
-
setForceGlobalBucketAccessEnabled
public void setForceGlobalBucketAccessEnabled(boolean forceGlobalBucketAccessEnabled) Option to enable or disable the usage of multi-region access point ARNs.- Default value
- false
-
setServiceEndpoint
The S3 service endpoint, either with or without the protocol. (e.g. https://sns.us-west-1.amazonaws.com or sns.us-west-1.amazonaws.com) -
setClientRegion
Name of the AWS region that the client is using.- Default value
- eu-west-1
-
setBucketName
-
setProxyHost
Proxy host -
setProxyPort
Proxy port -
setStorageClass
Set the desired storage class for the S3 object when action is move,copy or write. More info on storage classes can be found on the AWS S3 docs.- Default value
- STANDARD
-
setMaxConnections
public void setMaxConnections(int maxConnections) Maximum concurrent connections towards S3- Default value
- 50
-