Created
September 11, 2015 17:11
-
-
Save fastnsilver/fb750c02b58a04686509 to your computer and use it in GitHub Desktop.
Spring Integration AWS configuration fragment for synchronizing an S3 bucket directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public MessageSource<?> amazonS3InboundSynchronizationMessageSource() { | |
AWSCredentials credentials = new BasicAWSCredentials(this.accessKey, this.secretKey); | |
AmazonS3InboundSynchronizationMessageSource messageSource = new AmazonS3InboundSynchronizationMessageSource(); | |
messageSource.setCredentials(credentials); | |
messageSource.setBucket(bucket); | |
messageSource.setMaxObjectsPerBatch(maxObjectsPerBatch); | |
messageSource.setAcceptSubFolders(Boolean.valueOf(acceptSubFolders)); | |
messageSource.setRemoteDirectory(remoteDirectory); | |
if (!fileNameWildcard.isEmpty()) { | |
messageSource.setFileNameWildcard(fileNameWildcard); | |
} | |
String directory = System.getProperty(localDirectoryRef); | |
if (!localSubdirectory.startsWith("/")) { | |
localSubdirectory = "/" + localSubdirectory; | |
} | |
if (!localSubdirectory.endsWith("/")) { | |
localSubdirectory = localSubdirectory + "/"; | |
} | |
directory = directory + localSubdirectory; | |
FileUtils.mkdir(directory); | |
messageSource.setDirectory(new LiteralExpression(directory)); | |
return messageSource; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment