spring-integration-aws for s3 可以复制存储桶子目录吗?

Can spring-integration-aws for s3 replicate bucket subdirectories?

我将 https://github.com/spring-projects/spring-integration-aws 中的示例配置用于入站通道适配器,但我有一个包含内部 CSV 子目录的存储桶。

有没有办法在本地复制桶树结构?我只设法从子目录中复制文件,但它们最终是在我用 messageSource.setLocalDirectory(LOCAL_FOLDER);

设置的目录的根目录中创建的

或者有没有办法识别文件来自哪个存储桶子目录?

@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:

Starting with version 5.0, the Inbound Channel Adapter can build sub-directories locally according the generated local file name.

您需要从存储桶中提取,S3InboundFileSynchronizingMessageSource 将在本地目录中恢复一个结构。

注意:你需要使用,当然是最新的spring-integration-aws-2.0.0.RELEASE.