【发布时间】:2016-10-11 22:27:31
【问题描述】:
我想使用 FTP Streaming Channel Adapter 进行非常简单的示例,从 ftp 服务器读取文件,我阅读了文档,但我不清楚,
我设法将文件写入读取示例的 ftp 服务器,但是我无法以 InputStream 获取读取文件
<int:gateway service-interface="ftpmodule.service.FileWriterFTP"
default-request-channel="ftpOutChannel"/>
<int-ftp:outbound-channel-adapter
session-factory="ftpClientFactory" channel="ftpOutChannel"
remote-directory="/web/" remote-filename-generator-expression="headers['fileName']">
</int-ftp:outbound-channel-adapter>
还有我的课
public interface FileWriterFTP {
public void write(@Header("fileName") String fileName,@Payload String message);
public void write(@Header("fileName")String fileName,@Payload File file);
}
我运行应用程序,一切正常
public class AppConfig implements ApplicationRunner {
@Autowired
FileReaderFTP fileWriterFTP;
public static void main(String[] args) {
SpringApplication.run(AppConfig.class, args);
}
public void run(ApplicationArguments arg0) throws InterruptedException, ExecutionException, IOException {
fileWriterFTP.write("test.txt","test");
}
}
但我无法读取文件:
<int:channel id="ftpInChannel"/>
<int:gateway service-interface="ftpmodule.service.FileReaderFTP"
default-request-channel="ftpInChannel"/>
<int-ftp:inbound-streaming-channel-adapter session-factory="ftpClientFactory"
channel="ftpInChannel" filename-pattern="*.txt"
remote-file-separator="/" remote-directory="/web/">
</int-ftp:inbound-streaming-channel-adapter>
public interface FileReaderFTP {
public InputStream read(String fileName);
}
@Autowired
FileReaderFTP fileReaderFTP;
InputStream stream = fileReaderFTP.read("test.txt");
【问题讨论】:
标签: java spring ftp spring-integration