在 spring 集成 aws 应用程序中,使用 s3-outbound-gateway 将文件从源文件夹路由到目标 S3 存储桶。想使用文件到字符串转换器对文件进行 UTF-8/16 编码并上传到目标存储桶中。但是放置在目标存储桶中的输出文件没有编码,应用程序也不会抛出错误。
这里是否缺少任何东西以及实现此目的的任何其他方式?
<file:file-to-string-transformer input-channel="fileswithoutencoding" output-channel="filesOutS3Transformer" charset="UTF-8"/>
<!-- added this line -->
<integration:transformer input-channel="filesOutS3Transformer" output-channel="filesS3GateWay" expression="payload.bytes" />
<int-aws:s3-outbound-gateway id="s3File"
request-channel="filesS3GateWay"
reply-channel="filesS3ChainChannel"
transfer-manager="transferManager"
bucket-expression = "headers.TARGET_PATH"
key-expression="headers.file_name"
command="UPLOAD">
<int-aws:request-handler-advice-chain>
<ref bean="retryAdvice" />
</int-aws:request-handler-advice-chain>
</int-aws:s3-outbound-gateway>
路由到本地文件:文件仅使用文件到字符串转换器编码为 UTF-8 格式,尽管字符集是 8/16/32。
<integration:chain id="filesOutChain" input-channel="filesOut">
<integration:transformer expression="headers.FILE"/>
<file:file-to-string-transformer charset="UTF-16"/>
<!-- though bytes conversion is not required,just added for testing purpose -->
<integration:transformer expression="payload.bytes"/>
<file:outbound-gateway id="fileMover"
auto-create-directory="true"
directory-expression="headers.TARGET_PATH"
mode="REPLACE">
<file:request-handler-advice-chain>
<ref bean="retryAdvice" />
</file:request-handler-advice-chain>
</file:outbound-gateway>
<integration:gateway request-channel="filesOutChainChannel" error-channel="errorChannel"/>
</integration:chain>