Dynamic routing to putS3 Object based on file path
Hi,
We have a requirement to retrieve files from SFTP server and place into to different prefixes in a S3 bucket.
Mapping is something like this:
ftp path1 -> file pattern match1 -> s3 prefix1
ftp path1 -> file pattern match2 -> s3 prefix2
ftp path2 -> file pattern match3 -> s3 prefix3
ftp path3 -> match4 -> s3 prefix4
ListSFTP -> FetchSFTP -> RouteOnAttribute
RouteOnAttribute - Match1 (${filename:indexOf('pattern1'):gt(-1)}) - putS3Object1
RouteOnAttribute - Match2 (${filename:indexOf('pattern2'):gt(-1)}) - putS3Object2
We are using the ListSFTP, FetchSFTP and RouteOnAttribute to route it to the a corresponding putS3Object processor with different variables for different patterns.
We initially had only 2 patterns which grew into 10 - 15 patterns (Match1, Match2, .. Match N) to be routed to the corresponding paths. So if we follow the same approach we have to use 10 -15 putS3Object. Is there a way to avoid this?
Preferably is there a way to match patterns on the file names, to a lookup table to identify a prefix for the corresponding pattern?
Is there a pattern that we can use to achieve this?
Thank you

