我正在使用来自https://github.com/spring-projects/spring-integration-aws的样本配置作为入站通道适配器,但是我有一个存储桶,其中包含内部带有CSV的子目录。
有没有办法在本地复制存储桶树结构?我只能从子目录中复制文件,但是最终还是在我用messageSource.setLocalDirectory(LOCAL_FOLDER)设置的目录的根目录中创建了文件。
还是有办法识别文件来自哪个bucket子目录?
@Bean
@InboundChannelAdapter(value = "s3FilesChannel", poller = @Poller(fixedDelay = "100"))
public S3InboundFileSynchronizingMessageSource s3InboundFileSynchronizingMessageSource() {
S3InboundFileSynchronizingMessageSource messageSource =
new S3InboundFileSynchronizingMessageSource(s3InboundFileSynchronizer());
messageSource.setAutoCreateLocalDirectory(true);
messageSource.setLocalDirectory(LOCAL_FOLDER);
messageSource.setLocalFilter(new AcceptOnceFileListFilter<File>());
return messageSource;
}
您需要使用
/**
* Switch the local {@link FileReadingMessageSource} to use a custom
* {@link DirectoryScanner}.
* @param scanner the {@link DirectoryScanner} to use.
* @since 5.0
*/
public void setScanner(DirectoryScanner scanner) {
并指定一个RecursiveDirectoryScanner
:https : //docs.spring.io/spring-integration/docs/current/reference/html/ftp.html#_recovering_from_failures:
从版本5.0开始,入站通道适配器可以根据生成的本地文件名在本地构建子目录。
您需要从存储桶中拉出,S3InboundFileSynchronizingMessageSource
它将在本地目录中恢复结构。
注意:您当然需要使用最新的spring-integration-aws-2.0.0.RELEASE
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句