Reputation: 436
I have, I suppose, really newbie question but the fact is I'm newbie in spring framework. How can I upload files to, for example 'upload' folder loceted in root directory of my ftp server? I have tried this: My application context file:
<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="127.0.0.1"/>
<property name="username" value="test"/>
<property name="password" value="test"/>
<property name="clientMode" value="0"/>
<property name="fileType" value="2"/>
<property name="bufferSize" value="10000"/>
</bean>
<int:channel id="ftpChannel"/>
<int-ftp:outbound-channel-adapter id="outFtpAdapter"
channel="ftpChannel"
session-factory="ftpClientFactory"
remote-directory="/Users/test"/>
and my java code:
ConfigurableApplicationContext context =
new FileSystemXmlApplicationContext("/src/citrus/resources/citrus-context.xml");
MessageChannel ftpChannel = context.getBean("ftpChannel", MessageChannel.class);
File file = new File("/Users/test/test.txt");
Message<File> fileMessage = MessageBuilder.withPayload(file).build();
ftpChannel.send(fileMessage);
context.close();
But this example upload files to root directory. Thanks in advance.
Upvotes: 2
Views: 4656
Reputation: 21
Using FTPClient upload MultipartFiles to apache FTP server useful repo Hope this help for future search.
Upvotes: 1
Reputation: 121550
I've just tested it and work well:
<int-ftp:outbound-channel-adapter
id="sendFileToServer"
auto-create-directory="true"
session-factory="ftpSessionFactory"
remote-directory="/Users/test"/>
Where my FTP server is an embedded one and its root is:
[MY_USER_HOME]\Temp\junit7944189423444999123\FtpServerOutboundTests\
So the file is stored in the dir:
[MY_USER_HOME]\Temp\junit7944189423444999123\FtpServerOutboundTests\Users\test\
It is with the latest Spring Integration version.
Which is your version?
Upvotes: 1