Package org.frankframework.filesystem
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>
public class AmazonS3FileSystem
extends AbstractFileSystem<S3FileRef>
implements IWritableFileSystem<S3FileRef>, ISupportsCustomFileAttributes<S3FileRef>
-
Field Summary
Fields inherited from class org.frankframework.filesystem.AbstractFileSystem
log
Fields inherited from interface org.frankframework.filesystem.ISupportsCustomFileAttributes
FILE_ATTRIBUTE_PARAM_PREFIX
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Copies the file to another folder.void
createFile
(S3FileRef f, InputStream content) void
createFile
(S3FileRef f, InputStream content, Map<String, String> customFileAttributes) Creates a file with the given custom file attributes.void
createFolder
(String folder) software.amazon.awssdk.services.s3.S3Client
void
boolean
boolean
folderExists
(String folder) protected software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
long
protected software.amazon.awssdk.http.apache.ApacheHttpClient.Builder
Get a string representation of an identification of a file.int
getNumberOfFilesInFolder
(String folder) boolean
list
(String folder, TypeFilter filter) Lists files, directories or both, from a 'folder' or in the 'root' of the filesystem (when folder is null).Moves the file to another folder.void
open()
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.void
removeFolder
(String folder, boolean removeNonEmptyFolder) renameFile
(S3FileRef source, S3FileRef destination) Renames the file to a new name, possibly in a another folder.void
setAccessKey
(String accessKey) Access key to access to the AWS resources owned by the accountvoid
setAuthAlias
(String authAlias) Alias used to obtain AWS credentialsvoid
setBucketName
(String bucketName) Name of the bucket to access.void
setChunkedEncodingDisabled
(boolean chunkedEncodingDisabled) Setting this flag will result in disabling chunked encoding for all requests.void
setClientRegion
(String clientRegion) Name of the AWS region that the client is using.void
setForceGlobalBucketAccessEnabled
(boolean forceGlobalBucketAccessEnabled) Option to enable or disable the usage of multi-region access point ARNs.void
setMaxConnections
(int maxConnections) Maximum concurrent connections towards S3void
setProxyHost
(String proxyHost) Proxy hostvoid
setProxyPort
(Integer proxyPort) Proxy portvoid
setSecretKey
(String secretKey) Secret key to access to the AWS resources owned by the accountvoid
setServiceEndpoint
(String serviceEndpoint) The S3 service endpoint, either with or without the protocol.void
setStorageClass
(software.amazon.awssdk.services.s3.model.StorageClass storageClass) Set the desired storage class for the S3 object when action is move,copy or write.Creates a local S3Object pointer, not representative with what is stored in the S3 Bucket.Creates a reference to a file.Methods inherited from class org.frankframework.filesystem.AbstractFileSystem
getMaxNumberOfMessagesToList, isOpen, setMaxNumberOfMessagesToList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.frankframework.core.HasPhysicalDestination
getDomain
Methods inherited from interface org.frankframework.filesystem.IBasicFileSystem
getCanonicalNameOrErrorMessage, isOpen
Methods inherited from interface org.frankframework.filesystem.ISupportsCustomFileAttributes
getCustomFileAttributes, hasCustomFileAttributes
Methods inherited from interface org.frankframework.filesystem.IWritableFileSystem
appendFile
-
Constructor Details
-
AmazonS3FileSystem
public AmazonS3FileSystem()
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
ConfigurationException
-
open
- Specified by:
open
in interfaceIBasicFileSystem<S3FileRef>
- Overrides:
open
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceIBasicFileSystem<S3FileRef>
- Overrides:
close
in 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:
toFile
in interfaceIBasicFileSystem<S3FileRef>
-
toFile
Description copied from interface:IBasicFileSystem
Creates a reference to a file. If filename is not absolute, it will be created in 'defaultFolder'.- Specified by:
toFile
in interfaceIBasicFileSystem<S3FileRef>
-
getNumberOfFilesInFolder
- Specified by:
getNumberOfFilesInFolder
in interfaceIBasicFileSystem<S3FileRef>
- Overrides:
getNumberOfFilesInFolder
in classAbstractFileSystem<S3FileRef>
- Throws:
FileSystemException
-
list
Description copied from interface:IBasicFileSystem
Lists files, directories or both, from a 'folder' or in the 'root' of the filesystem (when folder is null). Only lists the objects as defined by the type filter.- Specified by:
list
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
exists
- Specified by:
exists
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
isFolder
- Specified by:
isFolder
in interfaceIBasicFileSystem<S3FileRef>
-
createFile
- Specified by:
createFile
in 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:
FileSystemException
IOException
-
createFile
public void createFile(S3FileRef f, InputStream content, Map<String, String> customFileAttributes) throws FileSystemException, IOExceptionDescription copied from interface:ISupportsCustomFileAttributes
Creates a file with the given custom file attributes.- Specified by:
createFile
in interfaceISupportsCustomFileAttributes<S3FileRef>
- Parameters:
f
-content
-customFileAttributes
-- Throws:
FileSystemException
IOException
-
createFile
- Specified by:
createFile
in interfaceIWritableFileSystem<S3FileRef>
-
appendFile
- Specified by:
appendFile
in 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:
readFile
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
deleteFile
- Specified by:
deleteFile
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
folderExists
- Specified by:
folderExists
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
createFolder
- Specified by:
createFolder
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
removeFolder
- Specified by:
removeFolder
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
renameFile
Description copied from interface:IWritableFileSystem
Renames the file to a new name, possibly in a another folder. Does not need to check for existence of the source or non-existence of the destination.- Specified by:
renameFile
in interfaceIWritableFileSystem<S3FileRef>
-
copyFile
public S3FileRef copyFile(S3FileRef s3Object, String destinationFolder, boolean createFolder) throws FileSystemException Description copied from interface:IBasicFileSystem
Copies 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:
copyFile
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
moveFile
Description copied from interface:IBasicFileSystem
Moves 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:
moveFile
in interfaceIBasicFileSystem<S3FileRef>
-
getAdditionalFileProperties
- Specified by:
getAdditionalFileProperties
in interfaceIBasicFileSystem<S3FileRef>
-
getName
Description copied from interface:IBasicFileSystem
Get 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:
getName
in interfaceIBasicFileSystem<S3FileRef>
-
getParentFolder
- Specified by:
getParentFolder
in interfaceIBasicFileSystem<S3FileRef>
-
getCanonicalName
- Specified by:
getCanonicalName
in interfaceIBasicFileSystem<S3FileRef>
-
getFileSize
- Specified by:
getFileSize
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
getModificationTime
- Specified by:
getModificationTime
in interfaceIBasicFileSystem<S3FileRef>
- Throws:
FileSystemException
-
getHttpClientBuilder
protected software.amazon.awssdk.http.apache.ApacheHttpClient.Builder getHttpClientBuilder() -
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in 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
Name of the bucket to access. The bucketName can also be specified by prefixing it to the object name, separated from it by "|" -
setProxyHost
Proxy host -
setProxyPort
Proxy port -
setStorageClass
public void setStorageClass(software.amazon.awssdk.services.s3.model.StorageClass storageClass) 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: https://aws.amazon.com/s3/storage-classes/- Default value
- STANDARD
-
setMaxConnections
public void setMaxConnections(int maxConnections) Maximum concurrent connections towards S3- Default value
- 50
-