[英]Sending Inputstream in spring integration
I have a project where I want to sending a pdf file to an ftp server.我有一个项目,我想将 pdf 文件发送到 ftp 服务器。
I am creating the file using pdfbox and changing it to an Inputstream and then I was to pass this input scream value to a remote FTP and save it as.pdf.我正在使用 pdfbox 创建文件并将其更改为输入流,然后将此输入尖叫值传递给远程 FTP 并将其另存为 .pdf。
I have the below code but not sure how I can pass the data to the outbound adapter.我有以下代码,但不确定如何将数据传递给出站适配器。
@Bean
public IntegrationFlow localToFtpFlow() {
return IntegrationFlows.from("toFtpChannel")
.handle(Ftp.outboundAdapter(sf())
.remoteDirectory("/ftp/forklift_checklist"))
.get();
}
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = "toFtpChannel")
void sendToFtp(InputStream file);
}
Not sure what why is the question.不知道为什么是这个问题。
What you have so far is OK:到目前为止你所拥有的是好的:
You call that sendToFtp()
gateway's method with an InputStream
for a local file.您使用本地文件的InputStream
调用sendToFtp()
网关的方法。
The Ftp.outboundAdapter(sf()
is based on the this.remoteFileTemplate.send(message, this.mode)
operation which really supports an InputStream
for a request payload: Ftp.outboundAdapter(sf()
基于this.remoteFileTemplate.send(message, this.mode)
操作,它真正支持请求负载的InputStream
:
else if (payload instanceof InputStream) { return new StreamHolder((InputStream) payload, "InputStream payload"); }
So, share with us, please, what the problem are you observing with your configuration?那么,请与我们分享您在配置中观察到的问题是什么?
Perhaps you are looking into a fileName
to give for that data while saving to FTP. Consider to have another gateway argument as a @Header(FileHeaders.FILENAME) String fileName
.也许您正在寻找一个fileName
以在保存到 FTP 时为该数据提供。考虑将另一个网关参数作为@Header(FileHeaders.FILENAME) String fileName
。 The RemoteFileTemplate
relies on a DefaultFileNameGenerator
which looks into that header by default. RemoteFileTemplate
依赖于默认情况下查看 header 的DefaultFileNameGenerator
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.