spring - How can I use S3InboundFileSynchronizer to synchronize an S3Bucket organized with directories? -
i'm trying use s3inboundfilesynchronizer synchronize s3bucket local directory. bucket organised sub-directories such as:
bucket -> 2016 -> 08 -> daily-report-20160801.csv daily-report-20160802.csv
etc...
using configuration:
@bean public s3inboundfilesynchronizer s3inboundfilesynchronizer() { s3inboundfilesynchronizer synchronizer = new s3inboundfilesynchronizer(amazons3()); synchronizer.setdeleteremotefiles(true); synchronizer.setpreservetimestamp(true); synchronizer.setremotedirectory("redacted"); synchronizer.setfilter(new s3regexpatternfilelistfilter(".*\\.csv$")); expression expression = parser.parseexpression("#this.substring(#this.lastindexof('/')+1)"); synchronizer.setlocalfilenamegeneratorexpression(expression); return synchronizer; }
i'm able far connecting bucket , listing contents. when comes time read bucket following exception thrown:
org.springframework.messaging.messagingexception: problem occurred while synchronizing remote local directory; nested exception org.springframework.messaging.messagingexception: failed execute on session; nested exception java.lang.illegalstateexception: 'path' must in pattern [bucket/key]. @ org.springframework.integration.file.remote.synchronizer.abstractinboundfilesynchronizer.synchronizetolocaldirectory(abstractinboundfilesynchronizer.java:266)
reviewing code seems it'd impossible ever synchronize s3bucket w/ sub-directories:
private string[] splitpathtobucketandkey(string path) { assert.hastext(path, "'path' must not empty string."); string[] bucketkey = path.split("/"); assert.state(bucketkey.length == 2, "'path' must in pattern [bucket/key]."); assert.state(bucketkey[0].length() >= 3, "s3 bucket name must @ least 3 characters long."); bucketkey[0] = resolvebucket(bucketkey[0]); return bucketkey; }
is there configuration i'm missing or bug?
(i'm assuming it's bug 'till i'm told otherwise i've submitted pull request proposed fix.)
yes, bug , submitted pullrequest fix.
only solution workaround custom sessionfactory<s3objectsummary>
returns custom s3session
extension provided fix in pr.
Comments
Post a Comment