Я хочу использовать FTP Streaming Channel Adapter для очень простого примера чтения файлов с ftp-сервера, я прочитал документацию, но мне это не понятно, Мне удалось записывать файлы на сервер FTP для чтения пример, но я не могу получить для чтения файлов в InputStream
Я не могу прочитать файл с ftp-сервера, FTP-потоковый входящий адаптер канала
<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");